Trailing slash issue with https redirect - Nginx

linsonj nginx-forum at
Wed Sep 23 10:02:14 UTC 2015


I'm using following settings for redirecting all http requests to https

Our nginx configuration is as follows

server {
listen 80;
server_name ~^(.*)\.mydomain\.com$;
set $servername $1;
rewrite ^(.*)$ https://$$1;
error_page 500 502 503 504 /50x.html;

SSL conf file

server {

listen 443 ssl;
server_name ~^(?<subdomain>.+)\.mydomain\.com$;
open_file_cache max=1000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;

location / {

root /var/www/html/WebApps1;


location /server {
proxy_pass http://mydomain/server;
proxy_set_header Host $;
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_temp_path /var/nginx/proxy_temp;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_redirect off;
proxy_cache sd6;
add_header X-Proxy-Cache $upstream_cache_status;
proxy_cache_bypass $http_cache_control;

We use wild card DNS. When we use, the static
pages loaded from location "/var/www/html/WebApps1" and API requests are
forwarded to

Issue is that when I try to access using current
setup, it is redirecting to ( with two
trailing slash at the end of url). Looking for a solution to remove this
double slash issue. 

I'm not sure what exactly the problem is. Any suggestion would be of great

Posted at Nginx Forum:,261751,261751#msg-261751

More information about the nginx mailing list