需求:由于购买了云上主机,只有一台跳板机有外网网卡,通过nginx反向代理实现内部服务器上网
1. 下载nginx 网址http://nginx.org/download/
2. 解压压缩包nginx-1.16.1.tar.gz
tar -xf nginx-1.16.1.tar.gz
3.编译安装
cd /data/nginx-1.16 ./configure --prefix=/data/nginx --with-http_stub_status_module --with-http_ssl_module --with-stream --with-http_sub_module --with-http_gzip_static_module
4. 下载环境
yum -y install gcc gcc-c++ autoconf automake make yum install pcre -y yum install pcre-devel -y yum install -y zlib yum install -y zlib-devel
5. 安装
make && make install
6.正向代理配置
server { resolver 114.114.114.114; #指定DNS服务器IP地址 listen 80; proxy_connect; proxy_connect_allow 443 563; proxy_connect_connect_timeout 10s; proxy_connect_read_timeout 10s; proxy_connect_send_timeout 10s; access_log logs/https.log main; location / { proxy_pass http://$host; proxy_set_header Host $host; } }
7. 客户机测试
curl -i --proxy 172.16.20.20:80 www.4399.com
8.配置yum
vim /etc/yum.conf proxy = http://172.16.20.20:80/