nginx ステージングは​​ポート番号を使用して http を https に書き換えます

nginx ステージングは​​ポート番号を使用して http を https に書き換えます

400 不正なリクエストが返されます。

これは設定コードです。ファイル: staging.rewrites

if ($scheme = http) {
   return 301 https://$host:[port]$request_uri;
}

これが有効な書き換えかどうか知っている人はいますか?

答え1

設定ファイルがどこにあるかはわかりませんが、ポート 80 で次の行を使用して、ポート 443 へのリクエストを書き換えることをお勧めします。

server {
    listen 80;

    server_name YOURSERVER_DOMAIN;

    access_log /var/log/nginx/access.http.log detailed;
    error_log /var/log/nginx/error.http.log notice;

    location / {
        rewrite ^ https://$host$request_uri? permanent;
    }
}

よろしく

答え2

これは、nginx で http -> https リダイレクトを実行するための推奨される方法です。

server {
    server_name example.com;

    return 301 https://www.example.com$request_uri;
}

関連情報