複数の仮想ホストをサポートするようにnginxウェブサーバを設定しています。ベストプラクティスに続いて、任意のhttp://要求を同等のhttps://にリダイレクトする必要があります。httpsにリダイレクトするようにnginxを設定する方法... 1つのディレクトリを除く
それほど簡単ですが、私は例外が1つあります。/.well-known/にあるファイルのリクエストは、httpsリダイレクトなしでhttpとして提供する必要があります。 LetsEncryptで働いている人は、LetsEncryptが検証ファイルを探す場所として '。well-known'ディレクトリを認識します。これらのは、HTTP経由で配信する必要があります。
これまでのところ、私がどのように見える「デフォルト」の設定ファイルがあります、そして、
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/default/www;
index index.php index.html index.htm;
location ^~ /.well-known/ {
allow all;
}
location/{
return 301 https://$host$request_uri;
}
}
を各仮想ホストのために、私がどのように見える別のファイルがあります:
server {
listen 443 ssl;
server_name myexamplevirtualhost.com;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
# lots more SSL-related stuff
location/{
try_files $uri $uri/ =404;
}
}
server {
listen 80;
server_name myexamplevirtualhost.com;
location/{
return 301 https://$server_name$request_uri;
}
location /.well-known/ { }
}
をたとえば、http://myexamplevirtualhost.com/
をリクエストした場合、私はhttps://myexamplevirtualhost.com/
にリダイレクトされます。これが私が望むものです。同様に、https://myexamplevirtualhost.com/
の直接要求も意図どおりに動作します。
しかし、私が試してみるとhttp://myexamplevirtualhost.com/.well-known/foo123
というサーバーが、単に目標であるhttp://myexamplevirtualhost.com/.well-known/foo123
を提供する代わりに、https://myexamplevirtualhost.com/.well-known/foo123
にリダイレクトします。
私は場所のルールの順番を変更するなど、さまざまなことを試しましたが、私はまだ自分が望む動作を得ることができません。
私は間違っていますか?
HTTP Strict Transport Securityがありますか? –
はい、個々のドメインのサーバブロックが含まれています:厳密-トランスポートセキュリティの最大エージングはadd_header = 15768000 うーんを。それは私の問題かもしれません。 – slamci