nginx configuration
Did a brew install of nginx which puts config files in /usr/local/etc/nginx
.
Then simplified the nginx.conf
file to this.
events {
worker_connections 1024;
}
include servers/*;
Added the following to /etc/hosts
.
127.0.0.1 note
Added servers/note.conf
.
http {
# So my goal here is to have all static stuff handled by nginx
# and everything else handled by node app.
server {
root /Users/jstein/github/take-note;
server_name note;
location / {
proxy_pass http://localhost:6543;
}
# So this allows nginx to serve index.html from
# /Users/jstein/github/take-note/html if the path matches /
# exactly. You can have parameters like /?foo=bar&zoo=man#whatever
location = / {
root html;
index index.html;
}
# This location is needed as well to serve index.html as /
location = /index.html {
# root /html; # 404 not found
# root html; # gives me /usr/local/var/www/index.html !?!
# don't know why i have to put full path in here.
root /Users/jstein/github/take-note/html;
}
# All the rest of our static assets besides index.html should
# be under specific folders. This is faster than regex and
# better organization.
location ^~ /img/ {
# let the poor users browser our img folder if they want,
# but then will need to specify the trailing slash.
autoindex on;
}
location ^~ /js/ {
autoindex on;
}
location ^~ /css/ {
autoindex on;
}
}
}
You can browse the app at http://note
or http://note/anything/but.the/excluded.folders
.
You can get a directory listing of the images, javascript or css at http://img/
, http://js/
, http://css/
. Trailing slash is required.