---
title: "nginx正向代理配置简单一例"
author: "李雨泽"
date: "2014-01-04T21:28:52Z"
tags: []
categories: ["开源软件"]
slug: "nginx"
draft: false
lastmod: "2014-01-05T13:43:12Z"
id: 1999051
url: "https://lichunhui.iteye.com/blog/1999051"
---

[Nginx](http://www.jbxue.com/server/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正向代理了。