nginx实现正向代理,下面以http为例说明:

(1)nginx配置:

server {
        listen       8080;
        resolver     114.114.114.114;

        access_log  logs/http.access.log  main;

        location / {
            proxy_pass http://$http_host$request_uri;
            root   html;
            index  index.html index.htm;
            proxy_set_header HOST $http_host;
            proxy_buffers 256 4k;
            proxy_max_temp_file_size 0k;
            proxy_connect_timeout 30;
            proxy_send_timeout 60;
            proxy_read_timeout 60;
            proxy_next_upstream error timeout invalid_header http_502;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
}

(2)重启nginx

(3)为浏览器配置http代理即可


好像不支持https,但网上有网友说可以,大家可以自己尝试。

 

posted on 2017-03-03 22:36  浮沉一梦  阅读(5487)  评论(0编辑  收藏  举报