我有一个简单的配置,将除了letsencrypt 请求之外的所有内容重定向到 https,然后我的虚拟主机只在 https 上..
目前我所有的请求都被重定向到 https,然后是 404 用于 letencrypt:
这是我的配置...
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
location ^~ /.well-known/acme-challenge/ {
allow all;
default_type text/plain;
return 200 "$1.abcd-efgh";
}
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl;
server_name plex.my_domain.com;
ssl_session_timeout 30m;
ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
ssl_certificate /root/.acme.sh/plex.my_domain.com/fullchain.cer;
ssl_certificate_key /root/.acme.sh/plex.my_domain.com/plex.my_domain.com.key;
ssl_session_cache shared:SSL:10m;
add_header X-Xss-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Strict-Transport-Security "max-age=2592000; includeSubdomains" always;
add_header X-Frame-Options "SAMEORIGIN" always; …Run Code Online (Sandbox Code Playgroud)