Redirecting to SSL using nginx

前端 未结 5 1710
傲寒
傲寒 2020-12-08 16:29

I have http:// and https:// on the same host like the following:

server {

    listen   80;
    listen   443 ssl;

    ...
    ...
}

What I

5条回答
  •  被撕碎了的回忆
    2020-12-08 16:45

    It would also be more of an NGINX best practice to do a 301 redirect instead of using the if statement (see Server name on http://wiki.nginx.org/Pitfalls). I created a gist with an nginx.conf configured for SSL, Rails and Unicorn

    https://gist.github.com/Austio/6399964

    Here would be the relevant section for yours.

    server {
        listen      80;
        server_name domain.com;
        return 301  https://$host$request_uri;
    }
    

提交回复
热议问题