Created
March 16, 2016 16:16
-
-
Save FUT/6d238cac3da63608423a to your computer and use it in GitHub Desktop.
Rails + Angular/Ember/React on the same server
This file contains hidden or 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
# | |
# 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