So I used this stackoverflow answer to try and set up my local (on osx) nginx server to have my node.js site that is getting successfully published to 127.0.0.1:3000 to appear at my_url.org in my browser. It isn't working.
Here is my nginx server: I've tried this both in the nginx.conf file directly and as a separate file which I created in the sites-available folder and then created the link to the sites-enabled folder (per the answer linked above)
upstream app_name {
server 127.0.0.1:3000;
keepalive 8;
}
server {
listen 0.0.0.0:80;
server_name my_url.org my_url;
access_log /usr/local/var/log/nginx/my_url.org.log;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://app_name/;
proxy_redirect off;
}
}
Some clues:
- I know the node is working because I can see the code at 127.0.0.1:3000
- I know the nginx.conf file is set up correctly because:
sudo nginx -t
tells me so and I have a seperate server within the nginx.conf file coming through correctly on port 8080. - So far any error logs are blank or non-existent.
- when I go to my_url.org I see the remote server on which the site is hosted. Not 127.0.0.1:3000.
- after every change I
sudo nginx -s reload
. - I've tried both
listen 80;
andlisten 0.0.0.0:80
with equal lack of success. - When I try this with the above code in the linked sites-enabled folder, I have the line
include /usr/local/etc/nginx/sites-enabled/*;
in the nginx.conf file. When I have the above code in the nginx.conf file, I comment that line out.
I'm assuming I'm missing something obvious but missing it I am. Any help wildly appreciated.