Last Updated: February 25, 2016
·
6.956K
· bartlomiejdanek

Nginx maintenance page

server {
        listen              80;
        server_name         _;

        location /__aws_elb_test {
                alias /srv/aws_elb_test/;
        }

        location / {
                rewrite ^(.*)$ https://example.com$1 permanent;
        }
}

server {
        listen              443;
        server_name         _;

        set $maintenance on;

        if ($uri ~* \.(ico|css|js|gif|jpe?g|png|html)(\?[0-9]+)? ) {
                set $maintenance off;
        }

        if ($maintenance = on) {
                return 503;
        }

        error_page 503 @maintenance;
        root /srv/example_com/current/public;
        location @maintenance {
                rewrite ^(.*)$ /maintenance.html break;
        }

        ssl                     on;
        ssl_certificate         /etc/ssl/private/example/example.com.crt;
        ssl_certificate_key     /etc/ssl/private/example/example.com.key;

        ssl_session_timeout     5m;

        ssl_protocols           SSLv2 SSLv3 TLSv1;
        ssl_ciphers             ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
        ssl_prefer_server_ciphers   on;
}