LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-21-2016, 04:10 PM   #1
Akram03
LQ Newbie
 
Registered: Feb 2016
Posts: 3

Rep: Reputation: Disabled
Trailing slash issue with https to http redirect (Nginx/BitrixVM/CentOS6.5)


Hello,

I'm using following settings for redirecting all http requests to https (BitrixVM on CentOS 6.5)

Nginx config:
Code:
s1.conf

	# Default website
	server {

		listen 80;
		server_name test.com www.test.com;
		return 301 https://test.com$request_uri;  # enforce https
		
		server_name_in_redirect off;
		
		access_log /var/log/nginx/access.log main;
		error_log  /var/log/nginx/error.log warn;
    
		proxy_set_header	X-Real-IP        $remote_addr;
		proxy_set_header	X-Forwarded-For  $proxy_add_x_forwarded_for;
		proxy_set_header	Host $host:80;
		proxy_set_header<	X-Forwarded-Host $http_host

		set $proxyserver	"http://127.0.0.1:8888";
		set $docroot		"/home/bitrix/www";

		index index.php;
		root /home/bitrix/www;

		# Redirect to ssl if need
		if (-f /home/bitrix/www/.htsecure) { rewrite ^(.*)$ https://$host$1 permanent; }

		# Include parameters common to all websites
		include bx/conf/bitrix.conf;

		# Include server monitoring locations
		include bx/server_monitor.conf;
	}

s1_ssl.conf

	# Default SSL certificate enabled website
	server {
		listen	443 default_server ssl;
		server_name test.com;
		return 301 https://test.com$request_uri;

		
		# Enable SSL connection
		include	bx/conf/ssl.conf;
		server_name_in_redirect	off;

		proxy_set_header	X-Real-IP	$remote_addr;
		proxy_set_header	X-Forwarded-For	$proxy_add_x_forwarded_for;
		proxy_set_header	Host		$http_host:443;
		proxy_set_header	X-Forwarded-Host $http_host;
		proxy_set_header    X-Forwarded-Proto https;


		proxy_set_header	HTTPS 		YES;

		set $proxyserver	"http://127.0.0.1:8888";
		set $docroot		"/home/bitrix/www";

		index index.php;
		root /home/bitrix/www;

		# Include parameters common to all websites
		include bx/conf/bitrix.conf;

		# Include server monitoring API's
		include bx/server_monitor.conf;

	}
When I try link like https://test.com/xyz/ all is ok, but when I try link without trailing slash https://test.com/xyz I get 400 Bad Request: The plain HTTP request was sent to HTTPS port
Code:
curl -I -k https://test.com/xyz

HTTP/1.1 301 Moved Permanently
Server: nginx/1.6.2
Date: Sun, 21 Feb 2016 21:54:47 GMT
Content-Type: text/html; charset=iso-8859-1
Connection: keep-alive
Location: http://test.com:443/xyz/
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
Any suggestion would be of great help.

Last edited by Akram03; 02-22-2016 at 02:31 PM. Reason: adding BB-codes
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Trailing slash issue with https redirect - Nginx linson_85 Linux - General 2 09-23-2015 11:43 PM
Nginx, Horde, Https, Redirect, This webpage has a redirect loop axetone Ubuntu 0 02-08-2015 10:44 PM
nginx force all http to https help sir-lancealot Linux - Server 1 02-13-2014 02:43 AM
Strange nginx redirects without trailing slash bzzik Linux - Server 11 02-27-2012 08:38 AM
no trailing slash -> apache redirect to microsoft site? SerfurJ Linux - Software 6 03-15-2005 06:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration