已解决
ngxin 正向代理配置 访问互联网
来自网友在路上 182882提问 提问时间:2023-11-04 06:09:50阅读次数: 82
最佳答案 问答题库828位专家为你答疑解惑
如果本地无法访问互联网,则通过nginx的正向代理,可以将本地的所有流量进行代理,从而达到访问互联网的目的,话不多说,上代码:
1、下载nginx并安装相关依赖
yum -y install gcc
yum install -y gcc-c++
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel
mkdir -p /mnt/soft/installPackage
cd /mnt/soft/installPackage
wget http://nginx.org/download/nginx-1.18.0.tar.gz
2、解压nginx压缩包
tar -zxvf nginx-1.18.0.tar.gz
3、下载正向代理插件,此插件为必须
yum install git
yum -y install patch
git clone https://gitee.com/web_design_of_web_frontend/ngx_http_proxy_connect_module.git
4、编译正向代理插件
cd /mnt/soft/installPackage/nginx-1.18.0
patch -p1 < /mnt/soft/installPackage/ngx_http_proxy_connect_module/patch/proxy_connect_rewrite_1018.patch
5、编译安装nginx
./configure --prefix=/usr/local/nginx --with-http_ssl_module --add-module=/mnt/soft/installPackage/ngx_http_proxy_connect_module
make && make install
安装目录:/usr/local/nginx
配置文件目录:/usr/local/nginx/conf/nginx.conf
6、配置正向代理
server {listen 9090;resolver 114.114.114.114 valid=60s ipv6=off;resolver_timeout 30s;proxy_connect;proxy_connect_allow 443 80;proxy_connect_connect_timeout 10s;proxy_connect_read_timeout 10s;proxy_connect_send_timeout 10s;location / {proxy_pass $scheme://$http_host$request_uri;proxy_set_header Host $host;proxy_http_version 1.1;#proxy_ssl_server_name on;}
}
7、启动nginx
cd /usr/local/nginx/sbin
./nginx
或
/usr/local/nginx/sbin/ngxin
8、开机自启动
cd /usr/lib/systemd/system/
vi nginx.service
#复制以下内容到nginx.service文件中[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
9、重启nginx,加入开机自启动
pkill -9 nginx
systemctl start nginx
systemctl enable nginx
10、配置系统代理
11、打开浏览器,访问外网地址,可以正常打开了
查看全文
99%的人还看了
相似问题
- 未来之路:互联网技术驱动汽车行业的创新浪潮
- “流量为王”的时代一去不返!如何押注互联网下一个黄金十年
- 腾讯觅影数智医疗影像平台获颁世界互联网领先科技成果大奖
- Java在互联网网络安全中的应用(三)
- 掌握互联网的未来:5G时代的新机遇
- Spring Cloud智慧工地源码,利用计算机技术、互联网、物联网、云计算、大数据等新一代信息技术开发,微服务架构
- 助力工业数字化!TDengine 与恩菲 MIM+ 工业互联网平台实现兼容性互认
- Docker网络模式_Docker常用命令_以及Docker如何给运行的镜像内容连接互联网_Docker网络模式原理---Docker工作笔记004
- ngxin 正向代理配置 访问互联网
- 如何理解互联网系统中的用户身份认证?
猜你感兴趣
版权申明
本文"ngxin 正向代理配置 访问互联网":http://eshow365.cn/6-31572-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!
- 上一篇: UOS安装Jenkins
- 下一篇: 大厂的 Git 代码管理规范是怎样的?