Created
November 16, 2015 08:21
-
-
Save duebbert/c1ab167a16e6cab6dd45 to your computer and use it in GitHub Desktop.
NGINX config to first check a server, e.g. webpack-dev-server, if it's down then local files.
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
server { | |
[... normal configs] | |
# Try webpack server first, if error 502 then go try files | |
location ~ ^/.+/static/js/.+\.js$ { | |
proxy_pass http://127.0.0.1:8080; | |
proxy_set_header X-Forwarded-Host 127.0.0.1:8080; | |
error_page 502 = @localjs; | |
} | |
# Trying js locally after webpack failed | |
location @localjs { | |
try_files $uri =404; | |
} | |
[... other locations] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Couldn't find something like this anywhere. The "try_files" directive works the other way round, i.e. first try local files then fallback (named location or internal).