linux 搭建 nginx正向代理 , 添加 第三方模块ngx_http_proxy_connect_module
apt-get install build-essential apt-get install libtool sudo apt-get update sudo apt-get install libpcre3 libpcre3-dev apt-get install zlib1g-dev apt-get install openssl apt-get install libssl-dev cd /usr/local wget https://nginx.org/download/nginx-1.20.1.tar.gz tar -xf nginx-1.20.1.tar.gz wget https://github.com/chobits/ngx_http_proxy_connect_module/archive/refs/heads/master.zip unzip master.zip cd nginx-1.20.1 patch -p1 < /usr/local/ngx_http_proxy_connect_module-master/patch/proxy_connect_rewrite_101504.patch ./configure \ --prefix=/usr/local/nginx \ --with-http_ssl_module \ --with-http_flv_module \ --with-http_stub_status_module \ --with-http_gzip_static_module \ --add-module=/usr/local/ngx_http_proxy_connect_module-master make && make install cd /usr/local/nginx/sbin ./nginx 启动nginx ./nginx -s stop 关闭nginx ./nginx -s reload 重启nginx
填加nginx 配置文件,实现nginx 正向代理
worker_processes auto; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; proxy_set_header HOST $host; proxy_buffers 256 4k; proxy_max_temp_file_size 1000k; proxy_connect_timeout 300; proxy_send_timeout 600; proxy_read_timeout 600; proxy_next_upstream error timeout invalid_header http_502; ############################################################ # 配置http正向代理 server { resolver 4.2.2.2; #指定DNS服务器IP地址 listen 8000; server_name 47.251.**.**; location / { proxy_pass http://$host$request_uri; #设定代理服务器 proxy_set_header Host $host; } } ############################################################ # 配置https正向代理 server { resolver 4.2.2.2; #指定DNS服务器IP地址 listen 4430; server_name 47.251.**.**; location / { proxy_pass https://$host$request_uri; #设定代理服务器的协议和地址 proxy_set_header Host $host; } } ############################################################ server { error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } server{ listen 8080; resolver 4.2.2.2 4.2.2.6; resolver_timeout 30s; proxy_connect; proxy_connect_allow 80 443; proxy_connect_timeout 10; proxy_send_timeout 600; proxy_read_timeout 600; location / { proxy_pass https://api.openai.com/v1/models; proxy_set_header Host $host; } } }
标签:http,18,module,nginx,源码,proxy,timeout,connect From: https://www.cnblogs.com/zyl88/p/17269456.html