NGINX,GeoIP,Varnish:太多的redirect

我拥有两台服务器。 一个在新加坡(data.example.me),另一个在欧洲(eu.data.example.me)。

我希望网站在访问我的网站时为他们最近的服务器提供服务。

我使用GeoIP模块在Signapore服务器上configuration了Nginx。

访问来自欧洲的网站(data.example.me)时,我收到“ERR_TOO_MANY_REDIRECTS”。 从其他地方它工作正常。

这是欧洲服务器上的configuration。 它已经安装了清漆

# Marker to tell the VCL compiler that this VCL has been adapted to the # new 4.0 format. vcl 4.0; # Default backend definition. Set this to point to your content server. backend default { .host = "139.51.1.1"; // Points to Nginx Server in Singapore .port = "80"; } 

在新加坡的Nginx服务器configuration如下。

 map $geoip_city_continent_code $closest_server { default data.example.me; EU eu.data.example.me; } server { listen 80 default_server; listen [::]:80 default_server; root /var/www/html; # Add index.php to the list if you are using PHP index index.php index.html index.htm index.nginx-debian.html /_h5ai/public/index.php; server_name data.example.me eu.data.example.me; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; autoindex on; # Site Settings (DDOS & Other Stuff) limit_req zone=one burst=10 nodelay; limit_conn addr 5; # Bandwidth Control limit_rate_after 102400K; limit_rate 5120K; } client_body_timeout 5s; client_header_timeout 5s; #GeoIP if ($closest_server != $host) { rewrite ^ $scheme://$closest_server$request_uri break; } # pass PHP scripts to FastCGI server # location ~ \.php$ { include snippets/fastcgi-php.conf; # # # With php-fpm (or other unix sockets): fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; # # With php-cgi (or other tcp sockets): # fastcgi_pass 127.0.0.1:9000; } location ~ /\.ht { deny all; } } server { listen 80; server_name 139.59.123.176; return 301 $scheme://data.vineethp.me$request_uri; } 

302 Foundredirect代码很可能是由您的应用程序而不是nginx返回的,因为在您的nginxconfiguration中没有对临时redirect的引用。