Routing your Node App using Nginx
Below is how to easily route to port 80 in your LEMP environment, you may need to edit your root path if your sites don't reside in /srv/
#listens for www.exampledomain.com then redirects without www
server {
listens 80;
server_name www.exampledomain.com;
return 301 $scheme://exampledomain.com$request_uri;
}
server {
listens 80;
server_name exampledomain.com;
index index.html;
root /srv/exampledomain.com/public/;
#routing to your Node app aka "Magic!"
location / {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X_Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 16m;
client_body_buffer_size 128k;
}
}
Written by Jack Keller
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Nodejs
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#