Skip to content

Instantly share code, notes, and snippets.

@FUT
Created March 16, 2016 16:16
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 FUT/6d238cac3da63608423a to your computer and use it in GitHub Desktop.
Save FUT/6d238cac3da63608423a to your computer and use it in GitHub Desktop.
Rails + Angular/Ember/React on the same server
#
# Define your upstream cluster
#
upstream rails {
server 0.0.0.0:3000 fail_timeout=0;
}
server {
listen 80;
server_name your_app.dev;
#
# This is the proxy to your API
#
location ~ ^/v1/api/(.+)$ {
sendfile off;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Protocol $scheme;
proxy_pass http://rails;
}
#
# This section serves the index.html of your Ember app
#
location ~ ^/$ {
sendfile off; # Don't know why, but necessary
alias /path/to/ember/;
try_files index.html =500; #index.html can not be found
}
#
# This section serves the other files of your Ember app
#
location ~ ^/(.+)$ {
sendfile off; # Same as above
alias /path/to/ember/;
try_files /$1 =404;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment