


Nginx Proxy Manager implements the deployment and configuration of multi-level cache
Nginx Proxy Manager is an open source reverse proxy server that can implement multi-level cache deployment and configuration. Through reasonable configuration, the performance and access speed of the website can be improved.
1. Install Nginx Proxy Manager
First, we need to install Nginx Proxy Manager. You can install it through the following steps:
- Update system packages: sudo apt update
- Install Nginx: sudo apt install nginx
- Install Node.js and npm: sudo apt install nodejs npm
- Download and install Nginx Proxy Manager: git clone https://github.com/jc21/nginx-proxy-manager.git
cd nginx-proxy-manager
npm install
npm run db:seed
2. Configure Nginx Proxy Manager
-
Modify the configuration file
Open the configuration file of Nginx Proxy Manager: sudo nano /etc/nginx/sites-available/default
Add the following configuration in the server section of the file:location / { proxy_pass http://127.0.0.1:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; }
Copy after loginChange 127.0.0.1:8080 in the above configuration to the upstream server address you actually use and port.
Configure cache
Open the cache configuration file of Nginx Proxy Manager: sudo nano /etc/nginx/nginx.conf
Add the following configuration in the http section:proxy_cache_path /path/to/cache levels=1:2 keys_zone=my_cache:10m max_size=10g inactive=60m; proxy_cache_key "$scheme$request_method$host$request_uri"; proxy_cache_valid any 10m; server { ... location / { proxy_cache my_cache; proxy_cache_valid 200 301 302 10m; proxy_cache_valid any 10s; proxy_cache_min_uses 1; proxy_cache_background_update on; proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504; proxy_cache_lock on; proxy_cache_lock_timeout 5s; proxy_pass http://127.0.0.1:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } ... }
Copy after loginReplace /path/to/cache in the above configuration with the path where you actually want the cache to be stored.
3. Testing and Effect
Restart Nginx: sudo systemctl restart nginx
Now, you can access the public IP address of the server through the browser and pass the request to the upstream server and caches the response. This way, when multiple users request the same resource, Nginx Proxy Manager will serve the response directly from the cache instead of re-requesting the upstream server.
4. Implement multi-level caching
If your architecture requires a higher level of caching, you can configure multiple Nginx Proxy Manager instances and connect them.
For example, you can set up an Nginx Proxy Manager instance as a front-end cache server and forward requests to another Nginx Proxy Manager instance, which acts as an upstream server. This way, the front-caching server will cache the response requested from the upstream server and serve the response directly from the cache on subsequent requests. Only when there is a cache miss will the front cache server request the upstream server.
The method of configuring multi-level cache is similar to configuring a single cache. You only need to configure the address and port of the pre-caching server to the address and port of the upstream server.
5. Summary
Through Nginx Proxy Manager, we can easily implement the deployment and configuration of multi-level cache. Properly configuring the cache can effectively improve the performance and access speed of the website and reduce the load on the upstream server. Hope the above content is helpful to you.
The above is the detailed content of Nginx Proxy Manager implements the deployment and configuration of multi-level cache. 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 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.

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.

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.

Steps to create a Docker image: Write a Dockerfile that contains the build instructions. Build the image in the terminal, using the docker build command. Tag the image and assign names and tags using the docker tag command.

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

In Linux, use the following command to check whether Nginx is started: systemctl status nginx judges based on the command output: If "Active: active (running)" is displayed, Nginx is started. If "Active: inactive (dead)" is displayed, Nginx is stopped.

Steps to start Nginx in Linux: Check whether Nginx is installed. Use systemctl start nginx to start the Nginx service. Use systemctl enable nginx to enable automatic startup of Nginx at system startup. Use systemctl status nginx to verify that the startup is successful. Visit http://localhost in a web browser to view the default welcome page.

To get Nginx to run Apache, you need to: 1. Install Nginx and Apache; 2. Configure the Nginx agent; 3. Start Nginx and Apache; 4. Test the configuration to ensure that you can see Apache content after accessing the domain name. In addition, you need to pay attention to other matters such as port number matching, virtual host configuration, and SSL/TLS settings.
