Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Nginx reverse proxy method of configuring multiple Wechat under one port 80

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the relevant knowledge of "Nginx reverse proxy how to configure multiple Wechat under a port 80". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this "Nginx reverse proxy method of configuring multiple Wechat under an 80 port" article can help you solve the problem.

Nginx reverse proxy configuration of multiple Wechat projects under one port 80

If we want to connect to the Wechat official account platform for development, we need to fill in the server configuration, and then according to the interface documents to achieve business logic. However, the official account interface of Wechat only supports interface 80 (port 80). Due to our business needs, we need to release two projects that need to be authorized by Wechat under an official domain name. What should we do?

We can use the nginx server as a reverse proxy to solve this problem. The nginx server has external port 80, and then accesses different items internally according to different url parameters.

The nginx configuration is as follows:

Open / usr/local/nginx/conf/nginx.conf

Worker_processes 4% errorcake 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 * buffers 16 64k * # point to item 1 upstream backend1 {server 192.168.1 proxy_cache_path 8081;} # point to item 2 upstream backend2 {192.168.1.1 upstream backend2 8082;} proxy_cache_path / tmp/cache levels=1:2 keys_zone=cache:128m inactive=1d max_size=1g; include vhosts/*;}

Open / usr/local/reverse_proxy_nginx/conf/nginx.conf

Worker_processes 2 upstream backend2 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 http 8181; server 192.168.1.1 VR 8081;} upstream backend2 {# server 192.168.1.1 http 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.htl; 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 301d; proxy_cache_valid any 1m; expires 30d; proxy_ignore_headers "cache-control"expires"set-cookie" This is the end of add_header nginx-res "http://backend1"; add_header nginx-cache" $upstream_cache_status ";} about" how to configure multiple Wechat under one port 80 of Nginx reverse proxy ". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report