nginx:“proxy_pass”不能在由正则expression式给出的位置或者在名为lo的内部具有URI部分

我正在使用nginx上游到不同的服务器组,取决于用户的地理位置。 因为看来geoip模块不会为本地地址(localhost,192.168.0.X等)返回任何值。 https://www.maxmind.com/en/faq

我试图ot处理这个如下:1)检查当前的IP是本地IP:

geo $isLanIP { default no; 192.168.0.0/24 yes; 127.0.0.1 yes; } 

2)取决于isLanIP proxy_pass的不同上行的值:

  if ($isLanIP ~ no){ proxy_pass http://$geoip_country_code.SearchControllerUpStream/; break; } if ($isLanIP ~ yes){ proxy_pass http://local.SearchControllerUpStream/; break; } 

当启动nginx时,错误“”proxy_pass“不能在正则expression式给定的位置,或者在名为lo的内部。 … .conf:64'被提出。 L64是第二个proxy_pass调用。

BR。

服务器块:

  server { listen 8080; server_name host; access_log /var/log/nginx/host.access.log main; error_page 404 = 404.html; error_page 403 = 403.html; root /home/user/app; location /SearchController { proxy_set_header Connection "Keep-Alive"; proxy_set_header Proxy-Connection "Keep-Alive"; if ($isLanIP ~ no){ proxy_pass http://$geoip_country_code.SearchControllerUpStream/; break; } if ($isLanIP ~ yes){ proxy_pass http://local.SearchControllerUpStream/; break; } limit_except POST { deny all; } } location / { include emergingthreats-deny.conf; include projecthoneypot-deny.conf; include spamhaus-deny.conf; index index.htm index.html; } }