【问题标题】:Nginx Conf conflict www 502Nginx Conf 冲突 www 502
【发布时间】:2021-07-18 07:40:38
【问题描述】:

我的网站使用 hsts http 重定向 https 工作,但是当我想使用 www 时,我的浏览器中有 502 nginx

我在面板中有别名www.mydomain.com

当我输入 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      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_*;
}

nginx.hsts.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


    【解决方案1】:

    NGINX 逐行或按字母顺序处理配置文件。

    这里发生的情况是您向 NGINX 提供了 2 个块,它们正在侦听端口 80。

    只需删除这部分,您就可以开始了。

    server {
    
    listen       80;
    
    server_name  www.mydomain.com;
    
    
    }
    

    【讨论】:

      猜你喜欢
      • 2023-02-01
      • 2015-01-06
      • 2015-02-23
      • 2012-04-16
      • 1970-01-01
      • 1970-01-01
      • 2015-08-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多