如何找到 Nginx 不必要的重定向的原因?

如何找到 Nginx 不必要的重定向的原因?

我使用 nginx 作为服务器。我有两个域名 abc.com 和 xyz.com。不知怎么的,我已将 abc.com 配置为转到 xyz.com,但我找不到在哪里。我在 sites-enabled 下为每个域都有一个文件,但重定向不在那里。我还检查了 nginx.conf,没有看到任何重定向。这个重定向可能来自哪里?有趣的是,当我从 sites-enabled 中删除 abc.com 服务器文件时,我收到 404 错误。sites-enabled 中的服务器文件如下所示:

server {
    server_name www.abc.com default_server;
    root /var/www/dev;
    index index.php;

    location / {
            try_files $uri $uri/ @handler;
    }
    location @handler {
        rewrite / /index.php;
    }
    location ^~ /html {
            try_files $uri $uri/;
    }
     location ^~ /phpmyadmin {
         alias /usr/share/phpmyadmin;
         auth_basic "Admin Login";
         auth_basic_user_file /etc/nginx/dbms_pass;
         index index.php index.html index.htm;
            location ~ \.php$ {
        include snippets/fastcgi-php.conf;
                    fastcgi_param SCRIPT_FILENAME $request_filename;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
                    }
    }

    location ^~ /livehelp {
            try_files $uri $uri/ /livehelp/index.php?$args;
                    location ~ /livehelp/.*\.php$ {
                            fastcgi_pass unix:/run/php/php7.0-fpm.sock;
                            include fastcgi_params;
                            fastcgi_param SCRIPT_FILENAME $request_filename;
                    }
    }

    location ^~ /livehelp/operator {
            try_files $uri $uri/ /livehelp/operator/index.php?$args;
                    location ~ /livehelp/operator/.*\.php$ {
                            fastcgi_pass unix:/run/php/php7.0-fpm.sock;
                            include fastcgi_params;
                            fastcgi_param SCRIPT_FILENAME $request_filename;
                    }
    }
   # Denied locations require a "^~" to prevent regexes (such as the PHP handler below) from mat$
    # http://nginx.org/en/docs/http/ngx_http_core_module.html#location
    location ^~ /app/                       { return 403; }
    location ^~ /includes/                  { return 403; }
    location ^~ /media/downloadable/        { return 403; }
    location ^~ /pkginfo/                   { return 403; }
    location ^~ /report/config.xml          { return 403; }
    location ^~ /var/                       { return 403; }
    location ^~ /lib/                       { return 403; }
    location ^~ /dev/                       { return 403; }
    location ^~ /RELEASE_NOTES.txt          { return 403; }
    location ^~ /downloader/pearlib         { return 403; }
    location ^~ /downloader/template        { return 403; }
    location ^~ /downloader/Maged           { return 403; }
    location ~* ^/errors/.+\.xml            { return 403; }
    location ^~ /rfqnet/    {return 403;}
    location ~ .php/ {
       rewrite ^(.*.php)/ $1 last;
    }
  location ~ \.php$ {
     fastcgi_split_path_info ^(.+\.php)(/.+)$;
       include snippets/fastcgi-php.conf;
        include fastcgi_params;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root/index.php;
        set $MAGE_ROOT /var/www/dev;
        set $MAGE_MODE developer;
    }

listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/www.abc.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/www.abc.com/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.abc.com) {
    return 301 https://$host$request_uri;
} # managed by Certbot
    server_name www.abc.com;
}

我应该在哪里检查以找出此不需要的重定向的原因?

相关内容