


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!

NGINX and Apache each have their own advantages and disadvantages, and the choice should be based on specific needs. 1.NGINX is suitable for high concurrency scenarios because of its asynchronous non-blocking architecture. 2. Apache is suitable for low-concurrency scenarios that require complex configurations, because of its modular design.

NGINXUnit is an open source application server that supports multiple programming languages and provides functions such as dynamic configuration, zero downtime updates and built-in load balancing. 1. Dynamic configuration: You can modify the configuration without restarting. 2. Multilingual support: compatible with Python, Go, Java, PHP, etc. 3. Zero downtime update: Supports application updates that do not interrupt services. 4. Built-in load balancing: Requests can be distributed to multiple application instances.

NGINXUnit is better than ApacheTomcat, Gunicorn and Node.js built-in HTTP servers, suitable for multilingual projects and dynamic configuration requirements. 1) Supports multiple programming languages, 2) Provides dynamic configuration reloading, 3) Built-in load balancing function, suitable for projects that require high scalability and reliability.

NGINXUnit improves application performance and manageability with its modular architecture and dynamic reconfiguration capabilities. 1) Modular design includes master processes, routers and application processes, supporting efficient management and expansion. 2) Dynamic reconfiguration allows seamless update of configuration at runtime, suitable for CI/CD environments. 3) Multilingual support is implemented through dynamic loading of language runtime, improving development flexibility. 4) High performance is achieved through event-driven models and asynchronous I/O, and remains efficient even under high concurrency. 5) Security is improved by isolating application processes and reducing the mutual influence between applications.

NGINXUnit can be used to deploy and manage applications in multiple languages. 1) Install NGINXUnit. 2) Configure it to run different types of applications such as Python and PHP. 3) Use its dynamic configuration function for application management. Through these steps, you can efficiently deploy and manage applications and improve project efficiency.

NGINX is more suitable for handling high concurrent connections, while Apache is more suitable for scenarios where complex configurations and module extensions are required. 1.NGINX is known for its high performance and low resource consumption, and is suitable for high concurrency. 2.Apache is known for its stability and rich module extensions, which are suitable for complex configuration needs.

NGINXUnit improves application flexibility and performance with its dynamic configuration and high-performance architecture. 1. Dynamic configuration allows the application configuration to be adjusted without restarting the server. 2. High performance is reflected in event-driven and non-blocking architectures and multi-process models, and can efficiently handle concurrent connections and utilize multi-core CPUs.

NGINX and Apache are both powerful web servers, each with unique advantages and disadvantages in terms of performance, scalability and efficiency. 1) NGINX performs well when handling static content and reverse proxying, suitable for high concurrency scenarios. 2) Apache performs better when processing dynamic content and is suitable for projects that require rich module support. The selection of a server should be decided based on project requirements and scenarios.


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

WebStorm Mac version
Useful JavaScript development tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 English version
Recommended: Win version, supports code prompts!
