我正在开发一个nodejs应用程序,我希望这个应用程序可以通过nginx的两个域(两个域指向同一个应用程序)访问,该应用程序部署在DigitalOcean droplet上,所以
假设我有我的应用程序: :port
和域一:example1.com
和域二:example2.com
我按照所有步骤为一个域设置 ssl,对第二个域也做了同样的操作,这是我的配置文件(它们位于可用站点中):config example1.com
`server {
listen 443 ssl;
server_name example1.com;
ssl_certificate /etc/nginx/ssl-1/example1.com.crt;
ssl_certificate_key /etc/nginx/ssl-1/example1.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}`
配置 example2.com
`
server {
listen 443 ssl;
server_name example2.com;
ssl_certificate /etc/nginx/ssl-2/example2.com.crt;
ssl_certificate_key /etc/nginx/ssl-2/example2.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}`
example11.com 工作正常,但 example2.com 不工作,谷歌浏览器给出这个警告
基本上,就是说example2.com的证书是为example1.com颁发的。
所以任何人都有在 nginx 上为同一个应用程序设置两个域的经验帮助我。