Nginx proxy_pass with $remote_addr

后端 未结 4 1011
时光说笑
时光说笑 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:00

    If the proxy_pass statement has no variables in it, then it will use the "gethostbyaddr" system call during start-up or reload and will cache that value permanently.

    if there are any variables, such as using either of the following:

    set $originaddr http://origin.example.com;
    proxy_pass $originaddr;
    # or even
    proxy_pass http://origin.example.com$request_uri;
    

    Then nginx will use a built-in resolver, and the "resolver" directive must be present. "resolver" is probably a misnomer; think of it as "what DNS server will the built-in resolver use". Since nginx 1.1.9 the built-in resolver will honour DNS TTL values. Before then it used a fixed value of 5 minutes.

提交回复
热议问题