The idea is to have nginx installed and node installed. Will extend this gist to include how to install those as well, but at the moment, the following assumes you have nginx and node installed on a linux distro (I used Ubuntu).
- nginx is used to serve static files (css, js, images, etc.)
- nginx.conf - changes required to allow proxying back thru to your node app.
So, www.foo.com request comes in
css, js, and images get served thru nginx
everything else (the request for say index.html or "/") gets served through node.
- nginx listens on port 80.
- node listens on port 8124.
So in your /etc/nginx/sites-available/default:
[...]
location / {
proxy_pass http://127.0.0.1:8124; #this is the ip:port where your node app runs
root /var/www/yoursitename;
expires 30d;
#uncomment this is you want to name an index file, otherwise a 403 will return:
#index index.php index.html;
access_log off;
}
location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm)$ {
root /var/www/yoursitename/public;
}
location /doc {
root /usr/share;
autoindex on;
allow 127.0.0.1;
deny all;
}
[...]
Restart nginx.
/etc/init.d/nginx restart
Restart your node app.
node /path/to/your/node/app.js
Navigate to your site and verify.