location /folder {
proxy_pass https://backend;
proxy_ssl_server_name on;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header Connection "upgrade";
}
merge_slashes off;
if ($request_uri ~* "\/\/") {
rewrite ^/(.*) $scheme://$host/$1 permanent;
}
if ($host != 'demo.ru') { return 301 https://demo.ru$request_uri;}
if ($scheme = 'http') { return 301 https://demo.ru$request_uri;}