亚洲中字慕日产2020,大陆极品少妇内射AAAAAA,无码av大香线蕉伊人久久,久久精品国产亚洲av麻豆网站

資訊專欄INFORMATION COLUMN

Nginx正向代理和反向代理配置

learn_shifeng / 3710人閱讀

摘要:前言的反向代理功能應(yīng)該是諸多功能里面最常用的一個(gè)功能了,正向代理的話可能使用的場(chǎng)景比較少,平時(shí)接觸的也不多,本章內(nèi)容僅包含這兩個(gè)功能的基本使用配置,因?yàn)槭潜镜匕姹镜?,所以不包含?fù)載均衡相關(guān)的內(nèi)容。

前言
Nginx的反向代理功能應(yīng)該是Nginx諸多功能里面最常用的一個(gè)功能了,正向代理的話可能使用的場(chǎng)景比較少,平時(shí)接觸的也不多,本章內(nèi)容僅包含這兩個(gè)功能的基本使用配置,因?yàn)槭潜镜匕姹镜模圆话?fù)載均衡相關(guān)的內(nèi)容。
完整配置和注釋
user   root owner;
worker_processes  4;

#error_log  /usr/local/etc/nginx/logs/error.log;
#error_log  /usr/local/etc/nginx/logs/info.log info;

pid        /Users/martin/nginx.pid;

events {
    worker_connections  256;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    #日志的格式
    #log_format  main  "$remote_addr - $remote_user [$time_local] "$request" "
    #                  "$status $body_bytes_sent "$http_referer" "
    #                  ""$http_user_agent" "$http_x_forwarded_for"";

    #訪問(wèn)日志
    #access_log  /usr/local/etc/nginx/logs/access_log_pipe  main;

    #sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    gzip  on;

    #反向代理配置

    server {
        listen       443 ssl;          #監(jiān)聽(tīng)443端口
        server_name  app.doodl6.com;   #服務(wù)域名
        ssl          on;               #是否開(kāi)啟SSL加密
        ssl_certificate         /Users/martin/Documents/ssl/doodl6.crt; # SSL加密證書(shū)
        ssl_certificate_key     /Users/martin/Documents/ssl/doodl6.key; # SSL加密秘鑰

        charset UTF-8;   #編碼指定

        location ~* ^.+.(xls|woff2|log|jpg|jpeg|gif|png|ico|html|cfm|cfc|afp|asp|lasso|pl|py|txt|fla|swf|zip|js|css|less)$ {   #代理指定后綴的請(qǐng)求,這里配的是常見(jiàn)的前端資源
            proxy_pass https://127.0.0.1:80;  #轉(zhuǎn)向提供內(nèi)容的真實(shí)服務(wù)器地址,也可以配置本地目錄(見(jiàn)HTTP代理配置)
            proxy_set_header Host $http_host;  #寫(xiě)入Header值,
            proxy_set_header referer "$http_referer";
        }  

        location = / {        #代理域名請(qǐng)求,也就只有域名的請(qǐng)求,如:https://app.doodl6.com
            proxy_pass https://127.0.0.1:8080;
            proxy_set_header Host $http_host;
        } 

        location ~ / {       #代理所有請(qǐng)求,不符合上面兩種配置的請(qǐng)求都會(huì)走這個(gè)代理配置
            proxy_pass http://127.0.0.1:8080;
            proxy_set_header Host $http_host;
        }
    }

    server {
        listen       80;
        server_name  app.doodl6.com;
        charset UTF-8; 

        location ~* ^.+.(xls|woff2|log|jpg|jpeg|gif|png|ico|html|cfm|cfc|afp|asp|lasso|pl|py|txt|fla|swf|zip|js|css|less|ico)$ {
            expires 30s;   #內(nèi)容緩存30秒
            root /Users/martin/project/app/front;  #指定文件根目錄
        } 

        location ~ / {
            proxy_pass http://127.0.0.1:8080;
            proxy_set_header Host $http_host;
        }
    }

    #正向代理配置

    server{
        listen 82;   #監(jiān)聽(tīng)端口 
        resolver 8.8.8.8;   #DNS
        resolver_timeout 10s;  # DNS解析超時(shí)時(shí)間
        location / {
            proxy_pass http://$http_host$request_uri;
            proxy_set_header Host $http_host;
            proxy_buffers 256 4k;
            proxy_max_temp_file_size 0;
            proxy_connect_timeout 30;
            proxy_cache_valid 200 302 10m;
            proxy_cache_valid 301 1h;
            proxy_cache_valid any 1m;
        }
    }

    #本地反向轉(zhuǎn)正向代理

    server {
        listen       80;
        server_name  proxy.doodl6.com;
        charset UTF-8; 

        location ~ / {
            proxy_pass http://127.0.0.1:82;  #轉(zhuǎn)到本地正向代理
            proxy_set_header Host $http_host;
        }
    }

}

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://www.ezyhdfw.cn/yun/40263.html

相關(guān)文章

  • Nginx實(shí)踐篇(4)- Nginx代理服務(wù) - 正向代理反向代理

    摘要:一代理簡(jiǎn)介代理代理服務(wù)正向代理和反向代理區(qū)別在于代理的對(duì)象不一樣。 一、代理簡(jiǎn)介 1. 代理 showImg(https://segmentfault.com/img/remote/1460000015873425?w=556&h=248); 2. Nginx代理服務(wù) showImg(https://segmentfault.com/img/remote/146000001587342...

    Keven 評(píng)論0 收藏0
  • Nginx實(shí)踐篇(4)- Nginx代理服務(wù) - 正向代理反向代理

    摘要:一代理簡(jiǎn)介代理代理服務(wù)正向代理和反向代理區(qū)別在于代理的對(duì)象不一樣。 一、代理簡(jiǎn)介 1. 代理 showImg(https://segmentfault.com/img/remote/1460000015873425?w=556&h=248); 2. Nginx代理服務(wù) showImg(https://segmentfault.com/img/remote/146000001587342...

    kidsamong 評(píng)論0 收藏0
  • Nginx實(shí)踐篇(4)- Nginx代理服務(wù) - 正向代理反向代理

    摘要:一代理簡(jiǎn)介代理代理服務(wù)正向代理和反向代理區(qū)別在于代理的對(duì)象不一樣。 一、代理簡(jiǎn)介 1. 代理 showImg(https://segmentfault.com/img/remote/1460000015873425?w=556&h=248); 2. Nginx代理服務(wù) showImg(https://segmentfault.com/img/remote/146000001587342...

    wuyangchun 評(píng)論0 收藏0
  • nginx反向代理、動(dòng)靜分離、負(fù)載均衡

    摘要:反向代理要說(shuō)反向代理,我們就先要理解正向代理下面我們就談?wù)務(wù)虼砗头聪虼戆???蛻舳瞬拍苁褂谜虼?。反向代理總結(jié)就一句話代理端代理的是服務(wù)端。因此,動(dòng)態(tài)資源轉(zhuǎn)發(fā)到服務(wù)器我們就使用到了前面講到的反向代理了。 反向代理 要說(shuō)反向代理,我們就先要理解正向代理 ,下面我們就談?wù)務(wù)虼砗头聪虼戆伞?正向代理 一個(gè)位于客戶端和原始服務(wù)器(origin server)之間的服務(wù)器,為了從原始...

    DTeam 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

最新活動(dòng)
閱讀需要支付1元查看
<