server {
        listen          *:80;
        listen          [::]:80;
        server_name     sandbox.yandex-team.ru sandbox-dev.yandex-team.ru;
        access_log      /var/log/nginx/sandbox_access.log stat;
        error_log       /var/log/nginx/sandbox_error.log error;

        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Scheme $scheme;

        error_page 405 = @405;
        location @405 {
            proxy_pass      http://127.0.0.1:9998;
        }

        location ~ ^/sandbox/resources/proxy(.*)$ {
            error_page 502 504 = @sandbox_backend;
            proxy_pass  http://127.0.0.1:9998;
            rewrite ^/sandbox/resources/proxy(.*)$ /sandbox/resources/redirect$1 break;
            proxy_redirect ~^http://(.*)$ http://proxy.sandbox.yandex-team.ru/$1;
        }

        location ~ ^/sandbox {
            error_page 502 504 = @sandbox_backend;
            proxy_pass  http://127.0.0.1:9998;
        }

        location /static/footer/ {
            proxy_pass http://127.0.0.1:9998;
        }

        location /api/ {
            error_page 502 504 = @sandbox_backend;
            proxy_pass http://127.0.0.1:9998;
        }

        location @sandbox_backend {
            proxy_pass      http://sandbox_backend;
        }

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