redirect from http to https
Steve Zhuo
lists at ruby-forum.com
Mon Mar 9 02:04:22 MSK 2009
Hi, thanks for the reply, i enable SSL on port 443, i just didn't paste
it. Here is a more complete version. if i use https://domain.com, it
works no problem, just when i tried to redirect from http to https, it
went into a redirect loop..
server {
listen 80;
server_name www.domain.com domain.com;
rewrite ^(.*) https://$server_name$1 permanent;
location / {
# needed for HTTPS
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;
}
}
server {
listen 443;
server_name www.domain.com domain.com;
ssl on;
ssl_certificate /path/myssl.crt;
ssl_certificate_key /path/myssl.key;
ssl_session_timeout 5m;
location / {
proxy_pass http://mysvr;
}
}
Thank You
Grzegorz Nosek wrote:
> On Sun, Mar 08, 2009 at 09:28:46PM +0100, Steve Zhuo wrote:
>> Hi
>>
>> I'm trying to redirect all income request from http to https: i've
>> tried the rewrite module , but i always got the redirect in a loop
>> issue. please help.
>
> You need to enable SSL on port 443.
>
>> listen 443;
>> server_name www.domain.com domain.com;
>
> + ssl_certificate /path/to/server.crt;
> + ssl_certificate_key /path/to/server.key;
> + ssl on;
>
>> .....
>> }
>
> Best regards,
> Grzegorz Nosek (replying by diffs is fun! ;))
--
Posted via http://www.ruby-forum.com/.
More information about the nginx
mailing list