Nginx Conf冲突www 502
我的网站使用hsts http重定向https工作,但当我想使用www时,我在浏览器中有502 nginx 面板中有别名 以及键入nginx-t时的日志错误 nginx:[警告]MYIP:80上存在冲突的服务器名“mydomain.com”,已忽略 nginx:[警告]0.0.0.0:80上的服务器名“www.mydomain.com”冲突,已忽略 Nginx.confNginx Conf冲突www 502,nginx,Nginx,我的网站使用hsts http重定向https工作,但当我想使用www时,我在浏览器中有502 nginx 面板中有别名 以及键入nginx-t时的日志错误 nginx:[警告]MYIP:80上存在冲突的服务器名“mydomain.com”,已忽略 nginx:[警告]0.0.0.0:80上的服务器名“www.mydomain.com”冲突,已忽略 Nginx.conf server { listen 80; server_name www.mydomain.com; }
server {
listen 80;
server_name www.mydomain.com;
}
server {
listen myIP:80;
server_name mydomain.com;
root /home/razor/web/mydomain.com/public_html;
index index.php index.html index.htm;
access_log /var/log/nginx/domains/mydomain.com.log combined;
access_log /var/log/nginx/domains/mydomain.com.bytes bytes;
error_log /var/log/nginx/domains/mydomain.com.error.log error;
include /home/razor/conf/web/mydomain.com/nginx.forcessl.conf*;
location / {
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
expires max;
fastcgi_hide_header "Set-Cookie";
}
location ~ [^/]\.php(/|$) {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_pass unix:/run/php/php7.4-fpm-mydomain.com.sock;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
}
}
location /error/ {
alias /home/razor/web/mydomain.com/document_errors/;
}
location ~* "/\.(htaccess|htpasswd)$" {
deny all;
return 404;
}
location /vstats/ {
alias /home/razor/web/mydomain.com/stats/;
include /home/razor/web/mydomain.com/stats/auth.conf*;
}
include /etc/nginx/conf.d/phpmyadmin.inc*;
include /etc/nginx/conf.d/phppgadmin.inc*;
include /home/razor/conf/web/mydomain.com/nginx.conf_*;
}
client_max_body_size 5G;
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
if (!-e $request_filename) { rewrite ^/(.*) /index.php?_page_url=$1 last; }
fastcgi_pass unix:/run/php/php8.0-fpm-php8.fhscript.com.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param MOD_X_ACCEL_REDIRECT_ENABLED on;
include /etc/nginx/fastcgi_params;
}
#location / {
if (!-e $request_filename) {
rewrite ^/(.*) /index.php?_page_url=$1 last;
}
#}
location /files/ {
internal;
}
# these locations would be hidden by .htaccess normally
location /logs/ {
deny all;
}
nginx.hsts.conf
server {
listen 80;
server_name www.mydomain.com;
}
server {
listen myIP:80;
server_name mydomain.com;
root /home/razor/web/mydomain.com/public_html;
index index.php index.html index.htm;
access_log /var/log/nginx/domains/mydomain.com.log combined;
access_log /var/log/nginx/domains/mydomain.com.bytes bytes;
error_log /var/log/nginx/domains/mydomain.com.error.log error;
include /home/razor/conf/web/mydomain.com/nginx.forcessl.conf*;
location / {
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
expires max;
fastcgi_hide_header "Set-Cookie";
}
location ~ [^/]\.php(/|$) {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_pass unix:/run/php/php7.4-fpm-mydomain.com.sock;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
}
}
location /error/ {
alias /home/razor/web/mydomain.com/document_errors/;
}
location ~* "/\.(htaccess|htpasswd)$" {
deny all;
return 404;
}
location /vstats/ {
alias /home/razor/web/mydomain.com/stats/;
include /home/razor/web/mydomain.com/stats/auth.conf*;
}
include /etc/nginx/conf.d/phpmyadmin.inc*;
include /etc/nginx/conf.d/phppgadmin.inc*;
include /home/razor/conf/web/mydomain.com/nginx.conf_*;
}
client_max_body_size 5G;
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
if (!-e $request_filename) { rewrite ^/(.*) /index.php?_page_url=$1 last; }
fastcgi_pass unix:/run/php/php8.0-fpm-php8.fhscript.com.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param MOD_X_ACCEL_REDIRECT_ENABLED on;
include /etc/nginx/fastcgi_params;
}
#location / {
if (!-e $request_filename) {
rewrite ^/(.*) /index.php?_page_url=$1 last;
}
#}
location /files/ {
internal;
}
# these locations would be hidden by .htaccess normally
location /logs/ {
deny all;
}
NGINX逐行或按字母顺序处理配置文件 这里发生的事情是,您已经向正在侦听端口80的NGINX提供了2个块 只要拆下这部分,你就可以开始了
server {
listen 80;
server_name www.mydomain.com;
}