https on a specific directory only?

TECK nginx-forum at
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:

server {
	listen default_server backlog=1024 rcvbuf=32k
	listen ssl;
	location / {
		try_files		$uri $uri/ /index.php?$uri&$args;

	location /dir/ {
		auth_basic		"Restricted Access";
		auth_basic_user_file	htpasswd;
		rewrite		^$request_uri? permanent;

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:,155918,155918#msg-155918

More information about the nginx mailing list