【发布时间】:2016-12-23 10:26:35
【问题描述】:
如果有人愿意为我提供有关如何让 NGINX 运行良好的任何提示,我将非常高兴。我想重定向https://www.subdomain.domain.com,但不幸的是,这对我现在不起作用。
请考虑我在 /etc/nginx/sites-available/default
中的以下 NGINX 设置server {
listen 443 ssl;
server_name subdomain.domain.com;
ssl_certificate /etc/letsencrypt/live/subdomain.domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/subdomain.domain.com/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-$
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:50m;
ssl_stapling on;
ssl_stapling_verify on;
add_header Strict-Transport-Security max-age=15768000;
server_name subdomain.domain.com; # Replace with your domain
root /home/dropshare/public_html;
index index.html index.htm;
client_max_body_size 10G;
location ~ /.well-known {
allow all;
}
}
server {
listen 80;
server_name subdomain.domain.com;
return 301 https://subdomain.domain.com$request_uri;
}
server {
listen 443 ssl;
server_name subdomain.domain.com;
return 301 https://subdomain.domain.com$request_uri;
}
【问题讨论】:
-
我没有看到您尝试将
www.subdomain.domain.com重定向到哪里? -
无论如何,首先您必须拥有
www.subdomain.domain.com域的有效证书。 -
您的配置文件或您的问题有点乱。您在一个
server块和最后一个服务器块中的server_name subdomain.domain.com中有重复的server_name指令(我认为应该是www.subdomain.domain.com。请编辑您的问题并澄清。 -
@AlexeyTen 谢谢!我认为我没有将 www.subdomain.domain.com 链接到它自己的证书(使用 Let's Encrypt)并在昨天修复了它。
-
@RichardSmith 我根据您的建议做了一些更改,非常感谢。我编辑了我的配置文件如下:paste.ee/r/uQDyP
标签: redirect ssl nginx https subdomain