mardi 31 mars 2015

How do you serve static files from an nginx server acting as a reverse proxy for a nodejs server?

My current nginx config is this:



upstream nodejs {
server 127.0.0.1:3000;
}

server {
listen 8080;
server_name localhost;
root ~/workspace/test/app;
index index.html;

error_log /usr/local/var/log/nginx/error.log;
access_log /usr/local/var/log/nginx/access.log;

location / {
proxy_pass http://nodejs;
proxy_set_header Host $host ;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}


I'm very very new to nginx, but at the very least I know that nginx is better than node/express at serving static files. How can I configure the server so that nginx serves the static files?


Aucun commentaire:

Enregistrer un commentaire