我为多个(3)域设置nginx。据我所知,当server_name匹配时,服务器应采用正确的服务器块。在我的情况下,我总是在默认块中。当我删除它,它需要下一个块。不是关于使用的域名。
这是我的配置:
server {
listen *:80 default_server;
listen *:443 default_server;
server_name _;
return 444;
}
server {
root /app/app-cluster/public;
index index.php;
server_name domain1.com;
location / {
try_files $uri /index.php$is_args$args;
}
location ~ ^/index\.php(/|$) {
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME
$realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
internal;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/domain1.com/fullchain.pem; #
managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/domain1.com/privkey.pem;
# managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
root /app/placeholder;
index index.html;
server_name domain2.com domain3.com
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/domain1.com/fullchain.pem; #
managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/domain1.com/privkey.pem;
# managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
答案 0 :(得分:1)
您的nginx配置包含一些错误。
例如,第一个服务器块根本没有配置SSL。
所以我假设您使用HTTP进行测试(而不是HTTPS),第一个服务器块捕获所有请求。