国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網(wǎng)站 > Nginx > 正文

Nginx反向代理一個(gè)80端口下配置多個(gè)微信項(xiàng)目詳解

2024-08-30 12:25:50
字體:
供稿:網(wǎng)友

Nginx反向代理一個(gè)80端口下配置多個(gè)微信項(xiàng)目詳解

 我們要接入微信公眾號(hào)平臺(tái)開發(fā),需要填寫服務(wù)器配置,然后依據(jù)接口文檔才能實(shí)現(xiàn)業(yè)務(wù)邏輯。但是微信公眾號(hào)接口只支持80接口(80端口)。我們因業(yè)務(wù)需求需要在一個(gè)公眾號(hào)域名下面,發(fā)布兩個(gè)需要微信授權(quán)的項(xiàng)目,怎么辦?

  我們可以用nginx服務(wù)器做反向代理來解決這個(gè)問題。nginx服務(wù)器對(duì)外80端口,然后根據(jù)URL參數(shù)不同,對(duì)內(nèi)訪問不同的項(xiàng)目。

  

  nginx配置如下:

  打開/usr/local/nginx/conf/nginx.conf

worker_processes 4;error_log logs/error.log;events {  worker_connections 1024;}http {  include    mime.types;  default_type application/octet-stream;  sendfile    on;  keepalive_timeout 65;gzip on;gzip_min_length 1k;gzip_buffers 16 64k;gzip_http_version 1.1;gzip_comp_level 6;gzip_types text/plain application/x-javascript text/css application/xml application/javascript;gzip_vary on;  #指向項(xiàng)目一  upstream backend1 {    server 192.168.1:8081;  }  #指向項(xiàng)目二  upstream backend2{    192.168.1.1:8082;  }  proxy_cache_path /tmp/cache levels=1:2 keys_zone=cache:128m inactive=1d max_size=1G;  include vhosts/*;}

  打開/usr/local/reverse_proxy_nginx/conf/nginx.conf

worker_processes 2;events {  worker_connections 1024;}http {  include    mime.types;  default_type application/octet-stream;  access_log /home/nginx_log/reverse_proxy_no1_access.log;  sendfile    on;  keepalive_timeout 65;  upstream backend1 {    #server 192.168.1.1:8181;  server 192.168.1.1:8081;  }  upstream backend2 {    #server 192.168.1.1:8082;  server 192.168.1.1:8082;  }  proxy_cache_path /tmp/cache levels=1:2 keys_zone=cache:128m inactive=30m max_size=1G;  server {    listen    8081;    server_name h5.xxxx.com;    location / {        proxy_pass http://backend1;      #Proxy Settings        proxy_redirect   off;       proxy_set_header  Host       $host;      proxy_set_header  X-Real-IP    $remote_addr;      proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;      proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;      proxy_max_temp_file_size 0;      proxy_connect_timeout   90;      proxy_send_timeout     90;      proxy_read_timeout     90;      proxy_buffer_size     4k;      proxy_buffers       4 32k;      proxy_busy_buffers_size  64k;      proxy_temp_file_write_size 64k;    add_header Nginx-Res "http://backend1";    }    location ~ ^/(h5)(.*)$ {        proxy_pass http://backend2;       proxy_redirect off;       proxy_set_header Host $host;       proxy_cache cache;       proxy_cache_valid 200 302 1d;       proxy_cache_valid 301 1d;       proxy_cache_valid any 1m;       expires 1h;     add_header Nginx-Res "http://backend2";       proxy_ignore_headers "Cache-Control" "Expires" "Set-Cookie";       add_header Nginx-Cache "$upstream_cache_status";     }        error_page  500 502 503 504 /50x.html;    location = /50x.html {      root  html;    }  location ~ .*/.(gif|jpg|png|css|js|ico)(.*) {       proxy_pass http://backend1;       proxy_redirect off;       proxy_set_header Host $host;       proxy_cache cache;       proxy_cache_valid 200 302 30d;       proxy_cache_valid 301 1d;       proxy_cache_valid any 1m;       expires 30d;       proxy_ignore_headers "Cache-Control" "Expires" "Set-Cookie";     add_header Nginx-Res "http://backend1";       add_header Nginx-Cache "$upstream_cache_status";    }            
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 民县| 建平县| 安阳市| 元江| 淄博市| 佛教| 伊宁市| 龙里县| 嵊州市| 乳山市| 巩留县| 容城县| 洮南市| 四川省| 噶尔县| 西城区| 天镇县| 凌云县| 营山县| 盐边县| 沂源县| 车致| 嵩明县| 长丰县| 容城县| 十堰市| 双流县| 壶关县| 定安县| 和静县| 霍邱县| 英德市| 汶川县| 稻城县| 那坡县| 广元市| 汉源县| 射阳县| 桑植县| 宁化县| 新巴尔虎左旗|