


How to configure multiple WeChat under Nginx reverse proxy port 80
nginx reverse proxy configures multiple WeChat projects under an 80 port Detailed explanation
If we want to access the WeChat public account platform for development, we need to fill in the server configuration and then implement it according to the interface document Business logic. However, the WeChat official account interface only supports interface 80 (port 80). Due to business needs, we need to publish two projects that require WeChat authorization under one official account domain name. What should we do?
We can use nginx server as a reverse proxy to solve this problem. The nginx server externally accesses port 80, and then accesses different projects internally based on different url parameters.
The nginx configuration is as follows:
Open /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; #指向项目一 upstream backend1 { server 192.168.1:8081; } #指向项目二 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/*; }
Open /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"; }
The above is the detailed content of How to configure multiple WeChat under Nginx reverse proxy port 80. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to configure Nginx in Windows? Install Nginx and create a virtual host configuration. Modify the main configuration file and include the virtual host configuration. Start or reload Nginx. Test the configuration and view the website. Selectively enable SSL and configure SSL certificates. Selectively set the firewall to allow port 80 and 443 traffic.

You can query the Docker container name by following the steps: List all containers (docker ps). Filter the container list (using the grep command). Gets the container name (located in the "NAMES" column).

Docker container startup steps: Pull the container image: Run "docker pull [mirror name]". Create a container: Use "docker create [options] [mirror name] [commands and parameters]". Start the container: Execute "docker start [Container name or ID]". Check container status: Verify that the container is running with "docker ps".

How to confirm whether Nginx is started: 1. Use the command line: systemctl status nginx (Linux/Unix), netstat -ano | findstr 80 (Windows); 2. Check whether port 80 is open; 3. Check the Nginx startup message in the system log; 4. Use third-party tools, such as Nagios, Zabbix, and Icinga.

Create a container in Docker: 1. Pull the image: docker pull [mirror name] 2. Create a container: docker run [Options] [mirror name] [Command] 3. Start the container: docker start [Container name]

The methods that can query the Nginx version are: use the nginx -v command; view the version directive in the nginx.conf file; open the Nginx error page and view the page title.

How to configure an Nginx domain name on a cloud server: Create an A record pointing to the public IP address of the cloud server. Add virtual host blocks in the Nginx configuration file, specifying the listening port, domain name, and website root directory. Restart Nginx to apply the changes. Access the domain name test configuration. Other notes: Install the SSL certificate to enable HTTPS, ensure that the firewall allows port 80 traffic, and wait for DNS resolution to take effect.

Starting an Nginx server requires different steps according to different operating systems: Linux/Unix system: Install the Nginx package (for example, using apt-get or yum). Use systemctl to start an Nginx service (for example, sudo systemctl start nginx). Windows system: Download and install Windows binary files. Start Nginx using the nginx.exe executable (for example, nginx.exe -c conf\nginx.conf). No matter which operating system you use, you can access the server IP
