网站首页 > 技术教程 正文
一、前言
1.1 正向代理功能比较简单,但是原生nginx不支持https代理,如果访问https网站,会报错。
# nginx代理不支持http CONNECT方法: curl: (56) Received HTTP code 400 from proxy after CONNECT
1.2 为了实现对https代理的支持,需要对原有nginx源码打补丁,就可以让nginx支持CONNECT模式了。
https://github.com/chobits/ngx_http_proxy_connect_module#build-openresty
二、下载并安装openresty
shell> yum -y install lua-devel shell> wget http://dlsw.91donkey.com/software/source/nginx/openresty-1.15.8.1.tar.gz shell> git clone https://github.com/chobits/ngx_http_proxy_connect_module.git shell> tar zxf openresty-1.15.8.1.tar.gz shell> vim bundle/nginx-1.15.8/auto/cc/gcc # 将下列代码注释掉,能够减少编译后nginx二级制文件的大小,提高程序执行效率。 # debug CFLAGS="$CFLAGS -g" shell> cd openresty-1.15.8.1 shell> ./configure --prefix=/opt/openresty --with-http_stub_status_module --with-http_sub_module \ --with-http_auth_request_module --with-http_addition_module \ --add-module=/usr/local/src/ngx_http_proxy_connect_module shell> patch -d build/nginx-1.15.8/ -p 1 < /usr/local/src/ngx_http_proxy_connect_module/patch/proxy_connect_rewrite_101504.patch shell> gmake -j 8 && gmake install shell> echo "/opt/openresty/nginx/sbin/nginx" >> /etc/rc.d/rc.local shell> /opt/openresty/nginx/sbin/nginx # 配置nginx vim语法高亮 shell> cd /usr/local/src/openresty-1.11.2.5/build/nginx-1.11.2/contrib/vim/ shell> mkdir ~/.vim/ && \cp -R * ~/.vim/
三、配置服务器端nginx正向代理
# 在nginx.conf中增加server{}块,具体如下:
server {
listen 8080;
resolver 8.8.8.8;
resolver_timeout 5s;
proxy_connect;
proxy_connect_allow 443 563;
proxy_connect_connect_timeout 10s;
proxy_connect_read_timeout 10s;
proxy_connect_send_timeout 10s;
location / {
proxy_pass $scheme://$host$request_uri;
proxy_set_header Host $http_host;
proxy_buffers 256 4k;
proxy_max_temp_file_size 0;
proxy_connect_timeout 30;
}
access_log /export/home/logs/proxy/access.log main;
error_log /export/home/logs/proxy/error.log;
}
四、配置终端代理
# 在 /etc/profile 文件中增加如下三项。
export proxy="http://{proxy_server_ip}:8080"
export http_proxy=$proxy
export https_proxy=$proxy
# 使配置生效
shell> source /etc/profile
作者:龍龍小宝
原文:https://www.cnblogs.com/91donkey/p/11639311.html
猜你喜欢
- 2024-10-10 可视化代理神器,动动手指轻松配置Nginx
- 2024-10-10 Nginx反向代理及参数配置(nginx反向代理原理及应用)
- 2024-10-10 经验分享:Nginx学习之反向代理WebSocket配置实例
- 2024-10-10 Nginx总结(五)如何配置nginx和tomcat实现反向代理
- 2024-10-10 Nginx代理WebSockets配置详解(nginx socks代理)
- 2024-09-11 写给前端同学的Nginx配置指南(前端 nginx)
- 2024-09-11 「Nginx」-Nginx主要配置速览(nginx常用配置)
- 2024-09-11 玩转Nginx你要知道这些配置(收藏篇)
- 2024-09-11 nginx配置详解(nginx基本配置)
- 2024-09-11 Nginx-常用配置详解(nginx简单配置)
欢迎 你 发表评论:
- 10-23Excel计算工龄和年份之差_excel算工龄的公式year
- 10-23Excel YEARFRAC函数:时间的"年份比例尺"详解
- 10-23最常用的10个Excel函数,中文解读,动图演示,易学易用
- 10-23EXCEL中如何计算截止到今日(两个时间中)的时间
- 10-2390%人不知道的Excel神技:DATEDIF 精准计算年龄,告别手动算错!
- 10-23计算工龄及工龄工资(90%的人搞错了):DATE、DATEDIF组合应用
- 10-23Excel中如何计算工作日天数?用这两个函数轻松计算,附新年日历
- 10-23怎样快速提取单元格中的出生日期?用「Ctrl+E」批量搞定
- 最近发表
-
- Excel计算工龄和年份之差_excel算工龄的公式year
- Excel YEARFRAC函数:时间的"年份比例尺"详解
- 最常用的10个Excel函数,中文解读,动图演示,易学易用
- EXCEL中如何计算截止到今日(两个时间中)的时间
- 90%人不知道的Excel神技:DATEDIF 精准计算年龄,告别手动算错!
- 计算工龄及工龄工资(90%的人搞错了):DATE、DATEDIF组合应用
- Excel中如何计算工作日天数?用这两个函数轻松计算,附新年日历
- 怎样快速提取单元格中的出生日期?用「Ctrl+E」批量搞定
- Excel日期函数之DATEDIF函数_excel函数datedif在哪里
- Excel函数-DATEDIF求司龄_exceldatedif函数计算年龄
- 标签列表
-
- 下划线是什么 (87)
- 精美网站 (58)
- qq登录界面 (90)
- nginx 命令 (82)
- nginx .http (73)
- nginx lua (70)
- nginx 重定向 (68)
- Nginx超时 (65)
- nginx 监控 (57)
- odbc (59)
- rar密码破解工具 (62)
- annotation (71)
- 红黑树 (57)
- 智力题 (62)
- php空间申请 (61)
- 按键精灵 注册码 (69)
- 软件测试报告 (59)
- ntcreatefile (64)
- 闪动文字 (56)
- guid (66)
- abap (63)
- mpeg 2 (65)
- column (63)
- dreamweaver教程 (57)
- excel行列转换 (56)

本文暂时没有评论,来添加一个吧(●'◡'●)