Nginx配置正向代理

nginx安装

参见:http://www.jianshu.com/p/affac5f2d56e

nginx配置正向代理

  • 配置/etc/nginx/nginx.conf,在http块中添加
http {
......
    include /etc/nginx/conf.d/*.conf;
}
  • 编写/etc/nginx/conf.d/http-proxy.conf
server {
    resolver 114.114.114.114;
    resolver_timeout 10s;
    listen 8000;

    location / {
        proxy_pass $scheme://$host$request_uri;
        proxy_set_header Host $http_host;
    }

    access_log  /var/log/nginx/access-http-proxy.log main;
}
  • 检测配置并重启nginx
# nginx -t
# /etc/init.d/nginx restart

你可能感兴趣的:(Nginx配置正向代理)