I'm building a server for serving static content, and uploading images there.
Everything works, but I'm not expert in nginx and server configuration, so maybe someone sees some improvements for this.
Here is my nginx config:
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location ~ \.(gif|jpg|png)$ {
gzip_static off;
root /var/www/assets;
}
location ~ \.(css|js)$ {
gzip_static on;
root /var/www/assets;
}
}
Users will upload and save images on this server, and I added node.js server for that with 1 view:
app.get('/upload', function (req, res) {...});
That's why I'm proxying server here:
location / { proxy_pass http://localhost:8080; ....
location ~ \.(gif|jpg|png)$ {`
I will serve images on this server
location ~ \.(css|js)$ {
I will serve js & css already gzipped on this server