Amazon ELBの背後にあるEC2マシンでウェブサイトを実行しています。
私はELB上でSSLを設定しています。そのため、httpsだけでなくHTTPも処理しています。 https上のすべてのリクエストは完全に機能します。しかし、HTTPリクエストをhttpsに強制的に(リダイレクトする)必要があります。何らかの理由で、動作しません。nginxのhttpsリダイレクトへのアクセス
nginxでリダイレクトルールを追加しましたが、そのルールを有効にするたびに、nginxサーバーが応答を停止します。ここで
server {
listen 80;
server_name domain1.com;
gzip on;
gzip_proxied any;
gzip_types text/plain text/xml text/css application/x-javascript;
gzip_vary on;
access_log /var/log/nginx/domain1.access.log;
location/{
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:4000/;
### Redirect http to https ####
if ($http_x_forwarded_proto != "https") {
rewrite ^(.*)$ https://$server_name$1 permanent;
}
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains;";
}
}
私は設定と間違っつもりどこに私を助けてください。 TIA。
は、使用傾ける理由は、' 301 HTTPSを返すことがありますか? –