重定向循环:Nginx仅显示特定子域的欢迎页面

时间:2020-10-16 22:06:18

标签: nginx

我定义了两个等价 nginx指令,例如:

server {
    listen 80;
    server_name translations.example.com;

    location / {
        proxy_pass http://localhost:8080;
    }
}

server {
    listen 80;
    server_name img.example.com;

    location / {
        proxy_pass http://localhost:9069;
    }
}

但是,我发现第一个仅显示nginx欢迎页面(地址栏中有124.26.119.135),而第二个按预期工作(img.example.com并显示img-service)。

直接通过IP地址和端口访问服务对它们两者均有效(例如124.26.119.135:8080124.26.119.135:9069)。

我看不出有什么区别吗?

nginx -t不返回任何错误或警告:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

进一步的分析表明,似乎存在一个重定向循环,不断获取301 Permanently moved,将translations.example.com重定向到124.26.119.135124.26.119.135等。

nginx日志显示:

185.21.102.132 - - [16/Oct/2020:22:35:32 +0000] "GET / HTTP/1.0" 301 185 "-" "SEO Consulting; Redirect Checker Tool V.02; IP:"
185.21.102.132 - - [16/Oct/2020:22:35:32 +0000] "GET / HTTP/1.0" 301 185 "-" "SEO Consulting; Redirect Checker Tool V.02; IP:"
185.21.102.132 - - [16/Oct/2020:22:35:32 +0000] "GET / HTTP/1.0" 301 185 "-" "SEO Consulting; Redirect Checker Tool V.02; IP:"
185.21.102.132 - - [16/Oct/2020:22:35:32 +0000] "GET / HTTP/1.0" 301 185 "-" "SEO Consulting; Redirect Checker Tool V.02; IP:"
185.21.102.132 - - [16/Oct/2020:22:35:32 +0000] "GET / HTTP/1.0" 301 185 "-" "SEO Consulting; Redirect Checker Tool V.02; IP:"
185.21.102.132 - - [16/Oct/2020:22:35:32 +0000] "GET / HTTP/1.0" 301 185 "-" "SEO Consulting; Redirect Checker Tool V.02; IP:"
185.21.102.132 - - [16/Oct/2020:22:35:32 +0000] "GET / HTTP/1.0" 301 185 "-" "SEO Consulting; Redirect Checker Tool V.02; IP:"
185.21.102.132 - - [16/Oct/2020:22:35:32 +0000] "GET / HTTP/1.0" 301 185 "-" "SEO Consulting; Redirect Checker Tool V.02; IP:"
185.21.102.132 - - [16/Oct/2020:22:35:32 +0000] "GET / HTTP/1.0" 301 185 "-" "SEO Consulting; Redirect Checker Tool V.02; IP:"
185.21.102.132 - - [16/Oct/2020:22:35:32 +0000] "GET / HTTP/1.0" 301 185 "-" "SEO Consulting; Redirect Checker Tool V.02; IP:"
185.21.102.132 - - [16/Oct/2020:22:35:32 +0000] "GET / HTTP/1.0" 301 185 "-" "SEO Consulting; Redirect Checker Tool V.02; IP:"
185.21.102.132 - - [16/Oct/2020:22:35:32 +0000] "GET / HTTP/1.0" 301 185 "-" "SEO Consulting; Redirect Checker Tool V.02; IP:"
185.21.102.132 - - [16/Oct/2020:22:35:32 +0000] "GET / HTTP/1.0" 301 185 "-" "SEO Consulting; Redirect Checker Tool V.02; IP:"
185.21.102.132 - - [16/Oct/2020:22:35:32 +0000] "GET / HTTP/1.0" 301 185 "-" "SEO Consulting; Redirect Checker Tool V.02; IP:"
185.21.102.132 - - [16/Oct/2020:22:35:32 +0000] "GET / HTTP/1.0" 301 185 "-" "SEO Consulting; Redirect Checker Tool V.02; IP:"
185.21.102.132 - - [16/Oct/2020:22:35:32 +0000] "GET / HTTP/1.0" 301 185 "-" "SEO Consulting; Redirect Checker Tool V.02; IP:"
185.21.102.132 - - [16/Oct/2020:22:35:32 +0000] "GET / HTTP/1.0" 301 185 "-" "SEO Consulting; Redirect Checker Tool V.02; IP:"
185.21.102.132 - - [16/Oct/2020:22:35:32 +0000] "GET / HTTP/1.0" 301 185 "-" "SEO Consulting; Redirect Checker Tool V.02; IP:"
185.21.102.132 - - [16/Oct/2020:22:35:32 +0000] "GET / HTTP/1.0" 301 185 "-" "SEO Consulting; Redirect Checker Tool V.02; IP:"
185.21.102.132 - - [16/Oct/2020:22:35:32 +0000] "GET / HTTP/1.0" 301 185 "-" "SEO Consulting; Redirect Checker Tool V.02; IP:"
185.21.102.132 - - [16/Oct/2020:22:35:32 +0000] "GET / HTTP/1.1" 301 185 "" "SEO Consulting; Redirect Checker Tool V.02; IP:"

域似乎已正确配置:

host -t A translations.example.bot产生translations.example.com has address 124.26.119.135,对于img.example.comimg.example.com has address 124.26.119.135返回相同的结果。

0 个答案:

没有答案