Created
March 2, 2016 17:12
-
-
Save rossanthony/b74d41347f030ef716f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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