The best way to force http request redirect to https in nginx

Use 301 redirect.
 
    server {
        listen  80;
        server_name blog.errong.win;
        return 301 https://$server_name$request_uri;
    }

    server {
        listen  80;
        server_name freevpn.errong.win;
        return 301 https://$server_name$request_uri;
    }

    server {
        listen  80;
        server_name www.errong.win errong.win;
        return 301 https://$server_name$request_uri;
    }

    server {
        listen       443 ssl;

        ssl_certificate      /etc/letsencrypt/live/errong.win/fullchain.pem;
        ssl_certificate_key  /etc/letsencrypt/live/errong.win/privkey.pem;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;

        server_name  ~^(.+)?\.errong\.win$;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   vhosts/$1;
            index  index.html index.htm;
        }
   } 
 
Remember reload your nginx server 
sudo sbin/nginx -s reload 

You can check with developer tool:
 

No comments:

Post a Comment

fixed: embedded-redis: Unable to run on macOS Sonoma

Issue you might see below error while trying to run embedded-redis for your testing on your macOS after you upgrade to Sonoma. java.la...