Nginx proxy_pass with $remote_addr

后端 未结 4 1008
时光说笑
时光说笑 2020-12-23 13:43

I\'m trying to include $remote_addr or $http_remote_addr on my proxy_pass without success.

The rewrite rule works

location ^~ /freegeoip/ {  
  rewri         


        
4条回答
  •  甜味超标
    2020-12-23 14:22

    If anyone is stll experiencing trouble, for me it helped to move the proxy_pass host to a seperate upstream, so I come up with something like this

    upstream backend-server {
      server backend.service.consul;
    }
    
    server {
      listen       80;
      server_name  frontend.test.me;
    
      location ~/api(.*)$  {
        proxy_pass http://backend-server$1;
      }
      location / {
        # this works mystically! backend doesn't...
        proxy_pass http://frontend.service.consul/;
      }
    }
    

提交回复
热议问题