Created
June 22, 2017 21:30
-
-
Save kitwalker12/acb51edce10481a375d409175fbb31c3 to your computer and use it in GitHub Desktop.
Nginx Proxy for Maintenance Page hosted on S3
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
server { | |
listen 80 default_server; | |
listen [::]:80 default_server; | |
# SSL Optional | |
listen 443 ssl default_server; | |
listen [::]:443 ssl default_server; | |
ssl_certificate /etc/ssl/my_cert.pem; | |
ssl_certificate_key /etc/ssl/my_cert.key; | |
root /var/www/html; | |
# Add index.php to the list if you are using PHP | |
index index.html index.htm index.nginx-debian.html; | |
server_name _; | |
resolver 8.8.8.8; | |
proxy_intercept_errors on; | |
error_page 403 404 500 502 503 @s3error; | |
proxy_set_header Authorization ""; | |
# Capture asset requests | |
location ~ .*/maintenance-page-files/(.*)$ { | |
proxy_pass http://my-bucket.s3.amazonaws.com/maintenance-page-files/$1; | |
} | |
# Capture all requests | |
location / { | |
set $indexfile "my-bucket.s3.amazonaws.com/maintenance-page.html"; | |
proxy_pass http://$indexfile; | |
} | |
# Redirect to Nginx error page instead of S3 error page | |
location @s3error { | |
internal; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment