可使用字段:location, location中的if字段
这个指令设置被代理服务器的地址和被映射的URI,地址可以使用主机名或IP加端口号的形式,例如:proxy_pass http://192.168.10.129/url
2.2、配置nginx配置文件nginx.conf
server { listen 80 default_server; server_name www.lansgg.com lansgg.com; access_log logs/lansgg.access.log main; error_log logs/lansgg.error.log; root /opt/nginx/nginx/html/lansgg; location / { index index.html; } location /other { proxy_pass http://192.168.10.129/other; proxy_set_header X-Real-IP $remote_addr; } }
2.3、配置client1
mkdir /var/www/html/otherecho "192.168.10.129" > /var/www/html/other/index.html
2.4、测试;
访问url: http://www.lansgg.com/other 你会发现跳转到了 : http://192.168.10.129/other/
查看日志:
[root@client1 ~]# tail -f /var/log/httpd/access_log 192.168.10.1 - - [06/Nov/2014:21:25:44 +0800] "GET /other/ HTTP/1.1" 200 15 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:32.0) Gecko/20100101 Firefox/32.0"
IIS7站长之家提示您:这篇文章你看完了!