目前正在 NGINX、Ubuntu 22.04 Vultr 服务器上安装 SSL。我在服务器上有两个现有域。为 Wordpress 多站点(子域基础)设置通配符 SSL,并且在 /sites-available/ 文件夹中设置我的网站配置文件时遇到困难。
我不确定如何解决这个问题。
我通过以下方式安装了 certbot
sudo certbot certonly --manual --preferred-challenges dns --server https://acme-v02.api.letsencrypt.org/directory -d '*.gethisyes.com' -d gethisyes.com
我将 TXT 记录质询添加到我的 DNS。一切顺利。
但现在尝试设置配置文件时,我收到“重复监听”选项错误。我不确定如何为 wordpress 多站点域设置通配符 SSL 的配置文件。
这是我当前的 /sites-available/site.com.conf 配置文件。
map $http_host $blogid {
default -999;
}
server {
listen 80;
server_name example.com *.example.com;
return 301 http://example.com$request_uri;
}
server {
listen 443 http2 ssl backlog=4096;
server_name example.com *.example.com;
root /var/www/example.com/public_html;
index index.php;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ ^/files/(.*)$ {
try_files /wp-content/blogs.dir/$blogid/$uri /wp-includes/ms-files.php?file=$1 ;
access_log off; log_not_found off; expires max;
}
#WPMU x-sendfile to avoid php readfile()
location ^~ /blogs.dir {
internal;
alias /var/www/example.com/html/wp-content/blogs.dir;
access_log off; log_not_found off; expires max;
}
include /etc/nginx/ssl/ssl_example.com.conf;
include /etc/nginx/ssl/ssl_all_examples.conf;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
include /etc/nginx/includes/fastcgi_optimize.conf;
}
include /etc/nginx/includes/browser_caching.conf;
access_log /var/log/nginx/access_example.com.log combined buffer=256k flush=60m;
error_log /var/log/nginx/error_example.com.log;
}
当我测试 nginx 配置文件时出现此错误
nginx: [emerg] duplicate listen options for 0.0.0.0:443 in /etc/nginx/sites-enabled/gethisyes.com.conf:13
nginx: configuration file /etc/nginx/nginx.conf test failed