Last active
July 28, 2020 22:44
-
-
Save emdecr/e807e5028670dc2a51faeba65305a44f to your computer and use it in GitHub Desktop.
Serve missing media from a production server when dev site is at a subdirectory.
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
# Case: Dev site hosted at subdirectory (NGINX) | |
# ie. https://dev.site/sub | |
# Serve Missing Media from a Production Server | |
# https://rzen.net/serve-missing-media-production-apache-nginx/ | |
location ~* \.(js|css|png|jpe?g|gif|ico)$ { | |
expires 24h; | |
log_not_found off; | |
try_files $uri $uri/ @production; | |
} | |
# Remove subdirectory from redirect | |
# https://stackoverflow.com/questions/33218367/nginx-proxy-pass-remove-path-prefix-resolve-dns | |
location @production { | |
resolver 8.8.8.8; | |
rewrite ^/sub/(.*) /$1 break; | |
proxy_pass https://production.site/$uri; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment