我有一台小型服务器,我想在其上动态加载多个域的 SSL 证书。
问题是我目前拥有的 2 个域名(domain.com 和 domain.cloud - “域名”相同)正在将我重定向到同一个domain.com
。我应该更改什么?
listen 80;
server_name domain.com domain.cloud;
access_log /var/log/nginx/root/access.log;
error_log /var/log/nginx/root/error.log warn;
# Redirect all http to https
location / {
return 301 https://$server_name$request_uri;
}
}
server {
listen 443 ssl;
server_name domain.com domain.cloud;
ssl_certificate /etc/ssl/$cert/cert.pem;
ssl_certificate_key /etc/ssl/$cert/privkey.pem;
access_log /var/log/nginx/root/access.log;
error_log /var/log/nginx/root/error.log warn;
root /var/www/root/pub;
index index.php;
location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
access_log off;
expires max;
log_not_found off;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
}
map $ssl_server_name $cert {
domain.com domain.com;
domain.cloud domain.cloud;
}
谢谢你!