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


my current nginx config this:

upstream nodejs {     server 127.0.0.1:3000; }  server {     listen 8080;     server_name localhost;     root ~/workspace/test/app;     index index.html;      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 new nginx, @ least know nginx better node/express @ serving static files. how can configure server nginx serves static files?

i solved using new configuration:

upstream nodejs {     server localhost:3000; }  server {     listen 8080;     server_name localhost;     root ~/workspace/test/app;      location / {         try_files $uri $uri/ @nodejs;     }      location @nodejs {         proxy_redirect off;         proxy_http_version 1.1;         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;     } } 

thanks following stack overflow post:


how serve existing static files directly nginx, proxy rest backend server.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -