【发布时间】:2016-11-07 06:38:12
【问题描述】:
我在尝试为 2 个域配置 SSL 时遇到了一些问题(在 link 之后)。请帮我!
我的上下文是:
- 我的服务器上有 2 个域:example.com 和 test.com
我想为以上 2 个域配置 SSL。这是配置:
档案/etc/nginx/sites-available/example:
server {
listen 80;
listen [::]:80;
server_name example.com www.example.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
include snippets/ssl-example.com.conf;
include snippets/ssl-params.conf;
root /home/user1/example-com;
index index.php index.html index.htm;
server_name example.com www.example.com;
location ~ ^/index.php/.*$ {
try_files $uri $uri/ /index.php?$args;
}
access_log /var/log/nginx/example-access.log;
error_log /var/log/nginx/example-error.log;
location ~ /.well-known {
allow all;
}
# other configurations
}
文件/etc/nginx/sites-available/test:
server {
listen 80;
listen [::]:80;
server_name test.com www.test.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
include snippets/ssl-example.com.conf;
include snippets/ssl-params.conf;
# include snippets/ssl-test.com.conf; # I tried with other file but it didn't work
# include snippets/ssl-params.conf;
root /home/user1/test-tk;
index index.php index.html index.htm;
server_name test.com www.test.com;
# Make site accessible from http://localhost/
# server_name test.com;
location ~ ^/index.php/.*$ {
try_files $uri $uri/ /index.php?$args;
}
access_log /var/log/nginx/test-access.log;
error_log /var/log/nginx/test-error.log;
location ~ /.well-known {
allow all;
}
# other configurations
}
重启nginx后没有任何错误。
我可以使用https://example.com/ 访问,第一个站点一切正常。但是对于第二个站点,它不起作用。访问链接 https://test.com/ 时,我收到警告“您的连接不是私有的”。
【问题讨论】:
-
显然您不能在
test.com上使用example.com的证书。所以你需要调查为什么ssl-test.com.conf不起作用。文件是否丢失,是否指向错误文件,证书文件是否丢失? -
谢谢@richard-smith。我使用了以下 2 个命令:
sudo letsencrypt certonly -a webroot --webroot-path=/home/user1/example-com -d example.com -d www.example.com和sudo letsencrypt certonly -a webroot --webroot-path=/home/user1/test-tk -d test.com -d www.test.com,但它仅适用于 example.com,不适用于 test.com。没有任何错误,请帮忙 -
nginx 和letsencrypt 有同样的问题
标签: ssl nginx lets-encrypt