node.js - Node + Nginx reverse proxy never works -


i've spent time trying work it's cutting actual development time. i'm trying set 2 domains on site example.com , example2.com navigating domain in browser results in 502 @ best.

the etc/nginx/nginx.conf got friend:

user root; worker_processes 4;   events {         worker_connections 768; }  http {          sendfile on;         tcp_nopush on;         tcp_nodelay on;         keepalive_timeout 65;         types_hash_max_size 2048;          server_names_hash_bucket_size 64;          include /etc/nginx/mime.types;         default_type application/octet-stream;          access_log /var/log/nginx/access.log;         error_log /var/log/nginx/error.log;           gzip on;         gzip_disable "msie6";          include /etc/nginx/sites-enabled/*; } 

the etc/nginx/sites-available/sites got friend:

server {     server_name example.com;     # proxy pass nodejs     location / {         proxy_pass    http://127.0.0.1:9001/;     } } server {     server_name example2.com;     # proxy pass nodejs     location / {         proxy_pass    http://127.0.0.1:8000/;     } } 

i've been working in circles , have tried many different configurations fail, specific 1 results in gateway error 502 both sites.

i've never been able work , have no idea why, second set of eyes helpful.

there nothing looks wrong in nginx configuration. if node server nginx trying forward connection not listening on port specify in configuration 502 status code.

to verify whether listening correctly, can use tool can connect port perform http get. so, instance:

$ curl http://127.0.0.1:9001/ 

or wget used this. if connection refused chances node server not running @ or configured listen on different port.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -