国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

NGINX編譯ngx_http_proxy_connect_module及做正向代理

這篇具有很好參考價(jià)值的文章主要介紹了NGINX編譯ngx_http_proxy_connect_module及做正向代理。希望對大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

NGINX編譯ngx_http_proxy_connect_module

1、下載NGINX(網(wǎng)址:http://nginx.org/download/ 當(dāng)前文檔使用版本為1.22.1)及ngx_http_proxy_connect_module模塊
[root@localhost work]# tar xzf nginx-1.22.1.tar.gz
[root@localhost work]# cd nginx-1.22.1
[root@localhost nginx-1.22.1]# git clone https://gitee.com/web_design_of_web_frontend/ngx_http_proxy_connect_module.git

2、下載該模塊的補(bǔ)丁包(需要通過打補(bǔ)丁的方式把上述下載的正向代理模塊導(dǎo)入到nginx模塊的存儲(chǔ)目錄中)
[root@localhost work]# wget https://gitcode.net/mirrors/chobits/ngx_http_proxy_connect_module/-/archive/master/ngx_http_proxy_connect_module-master.tar.gz
[root@localhost work]# tar xzf ngx_http_proxy_connect_module-master.tar.gz
[root@localhost work]# cd ngx_http_proxy_connect_module-master/patch
NGINX編譯ngx_http_proxy_connect_module及做正向代理,nginx,運(yùn)維,服務(wù)器

注:以下為各補(bǔ)丁包兼容版本
NGINX編譯ngx_http_proxy_connect_module及做正向代理,nginx,運(yùn)維,服務(wù)器

[root@localhost work]# patch -p1 < /root/work/ngx_http_proxy_connect_module-master/patch/proxy_connect_rewrite_102101.patch
NGINX編譯ngx_http_proxy_connect_module及做正向代理,nginx,運(yùn)維,服務(wù)器

注:File to patch處應(yīng)該填寫上方+++后面提示的ngx_http_core_module.c所在的目錄(本機(jī)所在目錄為/root/work/nginx-1.22.1/src/http/ ngx_http_core_module.c)

3、進(jìn)入到nginx-1.22.1目錄下編譯nginx
[root@localhost nginx-1.22.1]# ./configure
–prefix=/usr/local/nginx \
–sbin-path=/usr/local/nginx/sbin/nginx
–conf-path=/usr/local/nginx/conf/nginx.conf
–error-log-path=/var/log/nginx/error.log
–http-log-path=/var/log/nginx/access.log
–pid-path=/var/run/nginx.pid
–lock-path=/var/run/nginx.lock
–user=nginx --group=nginx
–http-client-body-temp-path=/var/cache/nginx/client_temp
–http-proxy-temp-path=/var/cache/nginx/proxy_temp
–http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp
–http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp
–http-scgi-temp-path=/var/cache/nginx/scgi_temp
–with-http_ssl_module
–with-http_realip_module
–with-http_addition_module
–with-http_sub_module
–with-http_dav_module
–with-http_flv_module
–with-http_mp4_module
–with-http_gunzip_module
–with-http_gzip_static_module
–with-http_random_index_module
–with-http_secure_link_module
–with-http_stub_status_module
–with-http_auth_request_module
–with-http_image_filter_module
–with-http_geoip_module
–with-http_slice_module
–with-http_v2_module
–with-threads
–with-stream
–with-stream_ssl_module
–with-mail
–with-mail_ssl_module
–with-file-aio
–with-compat
–add-dynamic-module=./ModSecurity-nginx
–add-dynamic-module=./nginx-rtmp-module
–add-dynamic-module=./nginx-module-vts
–add-dynamic-module=./ngx_http_proxy_connect_module #添加該模塊進(jìn)行編譯
[root@localhost nginx-1.22.1]# make
注:做升級(jí)或第二次編譯處理時(shí),不要做make install 操作,可能會(huì)覆蓋掉之前的配置,make后直接替換二進(jìn)制文件

4、替換nginx的二進(jìn)制文件
[root@localhost objs]# cp /root/work/nginx-1.22.1/objs/nginx /user/local/nginx/sbin/
[root@localhost objs]# cp /root/work/nginx-1.22.1/objs/ngx_http_proxy_connect_module.so /usr/local/nginx/modules/
注:替換二進(jìn)制文件前,停掉nginx服務(wù),將之前的二進(jìn)制文件備份到其他目錄

5、配置nginx
[root@localhost ~]# vi /usr/local/nginx/conf/nginx.conf
主配置文件內(nèi)添加:load_module modules/ngx_http_proxy_connect_module.so;
NGINX編譯ngx_http_proxy_connect_module及做正向代理,nginx,運(yùn)維,服務(wù)器

域名配置文件如下:

server {
    listen 8848;    #對外服務(wù)端口
    charset utf-8;
    resolver 114.114.114.114;    #配置DNS解析
    client_max_body_size  50m;
    access_log /data/log/outer_yunpian.com.log main_json;

    proxy_connect;    #開啟該模塊功能
    proxy_connect_allow            443 80;    #允許通過nginx訪問該域名80/443端口
    proxy_connect_connect_timeout  10s;
    proxy_connect_read_timeout     10s;
    proxy_connect_send_timeout     10s;

   location / {
       proxy_pass $scheme://$http_host$request_uri;    #設(shè)置代理地址
       proxy_set_header Host $host:$server_port;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto http;
       proxy_buffer_size 512k;
       proxy_buffers 6 512k;
       proxy_busy_buffers_size 512k;
       proxy_temp_file_write_size 512k;
     }

   location ~ /\.ht {
     deny all;
    } 

}

6、啟動(dòng)nginx服務(wù)

7、在需要做正向代理的客戶端服務(wù)器上配置環(huán)境變量進(jìn)行測試
[root@node2 ~]# vi /etc/profile
NGINX編譯ngx_http_proxy_connect_module及做正向代理,nginx,運(yùn)維,服務(wù)器

[root@node2 ~]# source /etc/profile
添加:
export http_proxy=http://192.168.1.11:8848
export https_proxy=http://192.168.1.11:8848
以上為nginx服務(wù)器IP及其代理端口
或者使用以下命令測試:curl --proxy 192.168.1.11:8848 http://www.yunpian.com
若添加了環(huán)境變量,則直接使用curl http://www.yunpian.com進(jìn)行測試文章來源地址http://www.zghlxwxcb.cn/news/detail-543402.html

到了這里,關(guān)于NGINX編譯ngx_http_proxy_connect_module及做正向代理的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包