CentOS 6下Nginx正向代理配置

CentOS 6下Nginx正向代理配置

By:老宁


一、环境介绍


wKioL1nlpO3jilqzAABTUbRtwbY625.png-wh_50

1、Client作为需访问访问互联网PC终端;

2、Nginx Server作为互联网出口代理服务器;

  • 内网网卡:192.168.1.100

  • 外网网卡:10.10.16.186

二、配置介绍

1、Nginx Server端配置:

[root@localhost]# cat /usr/local/Nginx/Nginx.conf

server {

listen 80; #监听80端口

server_name 192.168.1.100; #Server 的内容地址,与Client地址互通

resolver 8.8.8.8; #DNS

location / {

proxy_pass http://$http_host$request_uri; #$http_host和$request_uri是Nginx系统变量,不需要替换,保持原样

}

}

2、Client端配置:

[root@localhost ~]# export http_proxy=http://192.168.1.100:80 #设定变量环境,指定代理服务器IP地址及端口

测试:

[root@localhost ~]# wgetwww.baidu.com #可以成功访问百度

--2017-10-17 13:08:15-- http://www.baidu.com/

正在连接 192.168.1.100:80... 已连接。

已发出 Proxy 请求,正在等待回应... 200 OK

长度:未指定 [text/html]

正在保存至: “index.html.1”

[<=>] 99,762 --.-K/s in 0.07s

2017-10-17 13:08:16(1.36 MB/s) - “index.html.1” 已保存 [99762]

相关文章

Centos下搭建性能监控Spotlight
CentOS 6.3下Strongswan搭建IPSec VPN
在CentOS6.5上安装Skype与QQ
阿里云基于centos6.5主机VPN配置
CentOS 6.3下配置multipah
CentOS安装、配置APR和tomcat-native