nginx - /etc/nginx/sites-enabled/default 错误中 0.0.0.0:80 的重复默认服务器在哪里重复?
问题描述
我想我可能脑子有问题,但解决方案现在正在逃避我。启动时,Nginx 在 journalctl 中返回以下错误。
“/etc/nginx/sites-enabled/default 中 0.0.0.0:80 的重复默认服务器”
我看不到默认的副本。这是我启用站点的默认文件,其他任何人都可以指出错误的原因吗?
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
}
server {
listen 80;
listen [::]:80;
server_name demo4.review;
root /var/www/static;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}
server {
server_name wp.demo4.review;
root /var/www/wp_demo;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/wp.demo4.review/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/wp.demo4.review/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 = wp.demo4.review) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name wp.demo4.review;
return 404; # managed by Certbot
}
server {
listen 80;
server_name api.demo4.review;
location / {
proxy_pass http://localhost: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;
}
}
server {
if ($host = wp.demo4.review) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name wp.demo4.review;
listen 80;
return 404; # managed by Certbot
}
server {
server_name ukl.demo4.review;
root /var/www/ukl;
## This should be in your http block and if it is, it's not needed here.
index index.php;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/ukl.demo4.review/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/ukl.demo4.review/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 = ukl.demo4.review) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name ukl.demo4.review;
listen 80;
return 404; # managed by Certbot
}
解决方案
在 Nginx 也在读取的同一目录中有一个 default.save 文件。
推荐阅读
- python - 不和谐和机器人制作:我似乎无法让我的机器人发布网络解析材料
- javascript - 嵌套的 ES6 承诺 - 未捕获外部 func 错误
- python - Python SQL 数据导入 - 数据导入到数据库过程中去掉了反斜杠
- python - 使用 Py_SetPath() 和 Py_GetPath() 后的 Python C API free() 错误
- ruby-on-rails - 如何包含与 ActiveRecordSerializer 具有多态关联的嵌套资源?
- python-3.x - 如何在 highcharts-range 选择器行中选择一个按钮并单击
- php - 如何在 PHP、mysql 中进行分页
- android - Kotlin 等价于 Java 的 equalsIgnoreCase
- python - 在文件中搜索一行并将结果显示在带有文本的单独行上
- c# - 为什么使用 WebClient 的 UploadFileAsync 没有错误通知?