kavin

nginx如何配置正向代理

kavin nginx 2018-05-04 4110浏览 0

配置如下

server {

 listen 8090;

 location / {

 resolver 21.85.17.29 21.85.18.29;

 resolver_timeout 30s;

 proxy_pass http://$host$request_uri;

 }

 access_log  /data/httplogs/proxy-$host-aceess.log;      

}

  

测试:

http://www.94ip.com:8090

 

resolver指令

语法: resolver address ... [valid=time];

默认值:

配置段: http, server, location

配置DNS服务器IP地址。可以指定多个,以轮询方式请求。

nginx会缓存解析的结果。默认情况下,缓存时间是名字解析响应中的TTL字段的值,可以通过valid参数更改。

 

resolver_timeout指令

语法: resolver_timeout time;

默认值: resolver_timeout 30s;

配置段: http, server, location

解析超时时间。


继续浏览有关 nginx 的文章
发表评论