有一个我似乎无法理解的难题。
如果我启用这个特定站点“示例”,nginx 服务器将不会重新启动或执行任何操作,除非我禁用它。仅当我尝试使用 letsencrypt 启用 SSL 时才会出现此问题。
Ubuntu 20.04 LTS(如果这有区别的话),并且该项目是 Laravel 5.7
nginx -t 返回全部成功
是什么导致了这个问题/我应该从哪里开始寻找答案?
工作配置:
server {
listen 80;
server_name example.ca *.example.ca;
root /var/www/example/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
损坏的配置:
server {
server_name example.ca *.example.ca;
root /var/www/example/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/example.ca/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.ca/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 {
if ($host = www.example.ca) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = example.ca) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name example.ca *.example.ca;
return 404; # managed by Certbot
}
journalctl——xe:
-- A start job for unit nginx.service has begun execution.
--
-- The job identifier is 1074.
Sep 04 03:32:07 YDS-SERVER nginx[14844]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Sep 04 03:32:08 YDS-SERVER nginx[14844]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Sep 04 03:32:08 YDS-SERVER nginx[14844]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Sep 04 03:32:09 YDS-SERVER nginx[14844]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Sep 04 03:32:09 YDS-SERVER nginx[14844]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Sep 04 03:32:10 YDS-SERVER nginx[14844]: nginx: [emerg] still could not bind()
Sep 04 03:32:10 YDS-SERVER systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- An ExecStart= process belonging to unit nginx.service has exited.
--
-- The process' exit code is 'exited' and its exit status is 1.
Sep 04 03:32:10 YDS-SERVER systemd[1]: nginx.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- The unit nginx.service has entered the 'failed' state with result 'exit-code'.
Sep 04 03:32:10 YDS-SERVER systemd[1]: Failed to start A high performance web server and a reverse proxy server.
-- Subject: A start job for unit nginx.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A start job for unit nginx.service has finished with a failure.