NginxではHTTPSをHTTPに変更できません。

NginxではHTTPSをHTTPに変更できません。

nginxで動作するWebサーバーがあります。無料のドメイン名を登録し.tk、Let's Encrypt証明書をインストールしました。次の設定は私のHTTPSです。

if ($ssl_protocol = "") {
     rewrite ^ https://$server_name$request_uri? permanent;
}

ただし、NginxからすべてのHTTPS設定を削除した後にアクセスできなくなりました。http://mysite.tk。ブラウザでもキャッシュをクリアしましたが、動作しません。

修正する

私のものnginx.conf

#user  nobody;
worker_processes  4;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
    keepalive_timeout  65;

    gzip  on;

    server {
        listen       80;
        # listen       443 ssl;
        server_name  xxx.tk;


        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }


        # TLS configurations
  #       ssl_certificate      /etc/letsencrypt/live/xxx.tk/fullchain.pem;
  #       ssl_certificate_key  /etc/letsencrypt/live/xxx.tk/privkey.pem;

        # ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

  #       ssl_prefer_server_ciphers  on;
        # ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS !RC4";

        # add_header Strict-Transport-Security max-age=15768000;

        # if ($ssl_protocol = "") {
        #   rewrite ^ https://$server_name$request_uri? permanent;
        # }

        location / {
            index index.php index.html index.htm;
        }
        location /files {
            autoindex on;
        }

        location ~ \.php$ {
            root /home/tester/local/html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

    }

}

コメントから:

  • 設定を変更した後、デーモンを再起動しました。

  • Nginxもポート80でリッスンしています。次のように確認してください。

    netstat -pltun
    
  • ブラウザからすべてを消去しました。しかし、まだ動作しません。

ベストアンサー1

HTTPSをHTTPに戻すことができない最も可能性の高い理由は次のとおりです。

# add_header Strict-Transport-Security max-age=15768000;

今コメントされていますが、すでにテストしている可能性があります。

しかし、あなたは間違っていました。すべてのHSTSガイドは、HTTPSを介してドメインを配信できるという自信に基づいて時間の価値を高めるべきであることを知らなければならないからです。

おすすめ記事