Home  >  Q&A  >  body text

nginx ssl force jump

nginx makes port 80 forcefully jump to port 443.
Apart from,

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

Is there any other way to force http to jump to https?

我想大声告诉你我想大声告诉你2713 days ago647

reply all(5)I'll reply

  • 滿天的星座

    滿天的星座2017-05-16 17:17:07

    Isn’t this method good enough?

    server {
        listen      80;
        server_name file.demosite.com;
        
        location / {
            rewrite ^/(.*) https://file.demosite.com/ redirect;
        }
    }

    This is also possible

    reply
    0
  • 大家讲道理

    大家讲道理2017-05-16 17:17:07

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

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-05-16 17:17:07

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

    That’s it.

    reply
    0
  • 巴扎黑

    巴扎黑2017-05-16 17:17:07

    How to configure SSL certificate on Nginx (LNMP) and enable forced HTTPS
    https://echo.pm/lnmp-nginx-ss...

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-16 17:17:07

    HSTS, it’s difficult to type on a mobile phone, so I won’t describe it

    reply
    0
  • Cancelreply