Forcing SSL;

António P. P. Almeida appa at
Tue Feb 8 19:38:33 MSK 2011

On 8 Fev 2011 16h14 WET, david at wrote:

> Wouldn't that create an infinite loop?

No because they're listening on different ports. No need for an
if. Use two server blocks as suggested.

The server block for port 80 always does a permanent redirect do the
the same server but listening on 443 with a SSL socket. 

All the page processing happens at the server block for port 443.

server {
    ## This is to avoid the spurious if for sub-domain name
    ## rewriting. See
    listen [::]:80;
    rewrite ^$request_uri? permanent;
} # server domain rewrite.

server {
    listen [::]:443 ssl;
--- appa


More information about the nginx mailing list