redirect from http to https

mike mike503 at gmail.com
Mon Mar 9 04:43:43 MSK 2009


your proxy_set_header stuff would go where you proxy things, not on
your redirection

your http to https should be a simple

 server {
       listen       80;
       server_name  www.domain.com domain.com;
      rewrite     ^(.*)  https://$server_name$1 permanent;
}

this is literally one i have working flawlessly (just changed the domain):

        server {
                listen 80;
                server_name foo.com bar.com;
                rewrite ^/(.*) https://foo.com/$1 permanent;
        }


On Sun, Mar 8, 2009 at 4:08 PM, Steve Zhuo <lists at ruby-forum.com> wrote:
> Hi mike, i have a upstream portion:
>
> upstream mysvr   {
>        server 127.0.0.1 weight=1;
> }
>
>
> Is there other things i'm missing besides rewrite module to do the
> redirect from http to https?  I'm still new to nginx. any help is
> appreciated.. Thank You
>
>
>
> mike wrote:
>> On Sun, Mar 8, 2009 at 3:04 PM, Steve Zhuo <lists at ruby-forum.com> wrote:
>>> 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..
>>
>> i don't see why it would be (first off)
>>
>> try using lynx -mime_header http://foo.com/ and see what it says. i do
>> http to https all the time without an issue. you need to inspect the
>> headers and what is happening on the client side. firebug for firefox
>> or fiddler even could help too.
>>
>> why do you have this chunk? these headers are being sent to the
>> upstream and there is no upstream.
>>
>>> 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;
>>>        }
>>> }
>>
>>>
>>>
>>>  location / {
>>>      proxy_pass  http://mysvr;
>>
>> this would be where you would put the proxy_set_headers
>
> --
> Posted via http://www.ruby-forum.com/.
>
>





More information about the nginx mailing list