Skip to content

Instantly share code, notes, and snippets.

@faishal
Last active September 28, 2018 09:04
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 faishal/b21bb31231d534c57b69e7543517b95e to your computer and use it in GitHub Desktop.
Save faishal/b21bb31231d534c57b69e7543517b95e to your computer and use it in GitHub Desktop.
Nginx upload url proxy to production
# Solution 1 - Non http
# Directives to send expires headers and turn off 404 error logging.
location ~* .(js|css|png|jpg|jpeg|gif|ico)$ {
expires 24h;
log_not_found off;
try_files $uri $uri/ @production;
}
location @production {
resolver 8.8.8.8;
proxy_pass http://production-url/$uri;
}
# Solution 2
# For https mainly
location @production {
rewrite "^(.*)/wp-content/uploads/(.*)$" "https://production-url/wp-content/uploads/$2" redirect;
}
# Directives to send expires headers and turn off 404 error logging.
location ~ "^(.*)/wp-content/uploads/(.*)$" {
expires 24h;
log_not_found off;
try_files $uri $uri/ @production;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment