Reputation: 67
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:
sudo nginx -t
tells me so and I have a seperate server within the nginx.conf file coming through correctly on port 8080.sudo nginx -s reload
. listen 80;
and listen 0.0.0.0:80
with equal lack of success.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.
Upvotes: 3
Views: 148
Reputation: 4499
You should have to point my_url.org
to 127.0.0.1 in your hosts file (with linux and linux-like it should be in /etc/hosts
).
Otherwise your browser won't know to redirect to your local server.
(I answered in a comment, moving down here for future devs with same problem.)
Upvotes: 2