https on a specific directory only?

TECK nginx-forum at nginx.us
Mon Dec 6 10:48:58 MSK 2010


Hi all,

I recently purchased a SSL certificate and I would like to use it only
on a specific location:

[code]
server {
	listen				10.30.1.50:80 default_server backlog=1024 rcvbuf=32k
sndbuf=8k;
	listen				10.30.1.50:443 ssl;
	server_name			www.domain.com;
	ssl_certificate			domain.com.crt;
	ssl_certificate_key		domain.com.key;
...
	location / {
		try_files		$uri $uri/ /index.php?$uri&$args;
	}

	location /dir/ {
		auth_basic		"Restricted Access";
		auth_basic_user_file	htpasswd;
		rewrite		^	https://www.domain.com/dir$request_uri? permanent;
	}
...
}
[/code]

In other words, if you access the scheme with a http value, it redirects
you to the https scheme.
I really don't want to use any IF's as conditionals.
Right now, the rewrite creates a redirect loop. How can I fix that?

Thanks for your help.

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,155918,155918#msg-155918




More information about the nginx mailing list