Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Nginx Proxy for Maintenance Page hosted on S3
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