当前位置:首页>帮助中心>雷神HTTP—让nginx正向代理同时支持代理http和https请求

雷神HTTP—让nginx正向代理同时支持代理http和https请求

发布日期:2020-06-22 11:27:05 来源:雷神HTTP

默认情况下,nginx正向代理是支持代理http请求的,但是却不支持代理https请求,怎么办?

解决方案:

patch一个补丁包到nginx内核,下载补丁:ngx_http_proxy_connect_module

安装依赖【ubuntu】:

# sudo apt-get install libpcre3 libpcre3-dev zlib1g-dev openssl libssl-dev

patch步骤:

# wget http://nginx.org/download/nginx-1.9.2.tar.gz# tar xzvf nginx-1.9.2.tar.gz# cd nginx-1.9.2# patch -p1 < /path/to/ngx_http_proxy_connect_module/proxy_connect.patch# ./configure --add-module=/path/to/ngx_http_proxy_connect_module# make && make install

配置文件:

server {    resolver 114.114.114.114;    resolver_timeout 10s;    listen       7777;    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 http://$host;      proxy_set_header Host $host;      proxy_buffers 256 4k;      proxy_max_temp_file_size 0;      proxy_connect_timeout 30;    }}

注意事项:

1、多看 README.md;

2、支持如下nginx版本:

* 1.12.1 (stable version of 1.12.x)* 1.10.3 (stable version of 1.10.x)* 1.9.2 (stable version of 1.9.x)* 1.8.1 (stable version of 1.8.x)* 1.6.3 (stable version of 1.6.x)* 1.4.7 (stable version of 1.4.x)


用户登录

自动登录 忘记密码?

还没帐号?立即注册

用户注册

图形验证码

短信获取

我已阅读并同意 《用户协议》

已有账号?立即登录

忘记密码

图形验证码

短信获取

返回登录