nginx正向代理配置简单一例

Nginx正向代理配置如下:

server
{
  listen       8080;
  server_name www.jbxue.com;
  index index.html index.htm index.php;
  root  /home/wwwroot;
     location / {
         resolver        192.168.8.88;
         proxy_pass      $scheme://$http_host$request_uri;
         proxy_buffers   256 4k;
 }
   access_log off;
}

以上配置的注意事项:
1,不能有hostname。
2,必须有resolver, 即dns,即上面的x.x.x.x,换成当前机器的DNS服务器ip即可(查看dns方法 cat /etc/resolv.conf 代理使用)
3,$http_host和$request_uri是nginx系统变量,保持原样即可。

检测配置文件无误后,在浏览器中添加代理服务器的IP地址,就可以使用该Nginx正向代理了。

猜你喜欢

转载自lichunhui.iteye.com/blog/1999051