Skip to content

Instantly share code, notes, and snippets.

@rossanthony
Created March 2, 2016 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rossanthony/b74d41347f030ef716f9 to your computer and use it in GitHub Desktop.
Save rossanthony/b74d41347f030ef716f9 to your computer and use it in GitHub Desktop.
# Setting up nginx and node
Nginx
Any non-dynamic content should be served by Nginx since there is
no logic needed and it is something Nginx is great at, so why have
Node do it? The snippet below configures Nginx to listen on port 80
and serve static files from the web root. Each request is checked
to see if it's a POST or any other method with a JSON request type.
If either of those are true, the request is proxied on to a server
listening on port 8080, in our case the Node server.
server {
listen 80;
server_name localhost;
location / {
root /path/to/web/root/;
if ($request_method ~* POST) {
proxy_pass http://localhost:8080; }
if ($http_accept ~* application/json) {
proxy_pass http://localhost:8080; }
}
}
# Ref: http://blog.erlware.org/cowboy-and-batman-js-for-erlang-web-development/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment