Welcome! Log In Create A New Profile

Advanced

Trailing slash issue with https redirect - Nginx

September 23, 2015 06:02AM
Hello,

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://$servername.mydomain.com/$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 $subdomain.mydomain.com;
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 http_504;
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 https://webapp.mydomain.com, the static pages loaded from location "/var/www/html/WebApps1" and API requests are forwarded to https://mydomain.com/server


Issue is that when I try to access http://webapp.mydomain.com using current setup, it is redirecting to https://webapp.mydomain.com// ( 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 help.
Subject Author Posted

Trailing slash issue with https redirect - Nginx

linsonj September 23, 2015 06:02AM

Re: Trailing slash issue with https redirect - Nginx

nanaya September 23, 2015 06:12AM

Re: Trailing slash issue with https redirect - Nginx

linsonj September 23, 2015 07:25AM

Re: Trailing slash issue with https redirect - Nginx

nanaya September 23, 2015 07:28AM

Re: Trailing slash issue with https redirect - Nginx

locojohn September 23, 2015 07:55AM

Re: Trailing slash issue with https redirect - Nginx

linsonj September 24, 2015 12:39AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 56
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 214 on March 20, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready