In the daily operation of AnQiCMS, we deeply understand that stable and efficient content release is the cornerstone of success.When you try to deploy AnQiCMS through Docker in the aaPanel environment, you may occasionally encounter a situation where the automated reverse proxy configuration fails.This is usually not a fatal problem, but it requires us to manually intervene and calibrate the configuration to ensure that AnQiCMS can provide normal external services through your domain.
Understand the necessity of reverse proxy
In the Docker environment, AnQiCMS typically runs inside a container and is bound to a specific internal port (such as the default 8001 port). Users cannot access it directly.服务器IP:8001
Preparation: Confirm the AnQiCMS container status
Before starting to configure the reverse proxy, it is first necessary to confirm that the AnQiCMS Docker container itself is already running.You can log in to the aaPanel panel and navigate to the "Docker" or "Container" management interface to check the status of the AnQiCMS container.If the container is displayed as "Running" and you are sure it is configured to listen on the host's port 8001 (which is the default mapping port for the AnQiCMS Docker image), then we can continue to manually configure the reverse proxy.If the container is not running, you need to check the Docker container's startup issues first.
Manually configure Nginx reverse proxy in aaPanel
As aaPanel usually defaults to using Nginx as the web server, we will first introduce the reverse proxy configuration of Nginx.
First, you need to log in to your aaPanel management interface.Find the 'Website' option in the left navigation bar and click to enter.Here, you may have already created a website for your domain, or you may need to create a new website to host AnQiCMS services.
If the automated deployment fails, it usually means that the existing website configuration is not correctly pointing to the AnQiCMS container.You can edit the website settings of an existing domain or create a new website and select the 'Reverse Proxy' type.In the interface for creating or editing websites, find the settings related to reverse proxy.
The key configuration is in the "target URL" or "proxy address". Here, you need to fill in the port address exposed by the AnQiCMS Docker container on the host, which is usuallyhttp://127.0.0.1:8001. Here,127.0.0.1It refers to your server's local loopback address, while8001it is the port that the AnQiCMS container is mapped to the host. Make sure that your domain name has been correctly resolved to the server's IP address.
After completing these steps, aaPanel usually automatically generates the Nginx configuration file.To ensure the robustness of the configuration and the normal operation of AnQiCMS, we also need to check or manually modify the Nginx configuration file.In the website settings interface, click the 'Configure' button next to the domain name to enter the Nginx configuration file editing page.
You need to ensure that the configuration file includes the following or similar Nginx reverse proxy rules, which will forward all requests to your domain name to the AnQiCMS container:
location @AnqiCMS {
proxy_pass http://127.0.0.1:8001;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
error_page 404 =200 @AnqiCMS;
location / {
try_files $uri $uri/index.html @AnqiCMS;
}
The meaning of this configuration is:
proxy_pass http://127.0.0.1:8001;This is the core instruction, telling Nginx to forward requests to the local 8001 port.proxy_set_header Host $host;Pass the original Host request header to AnQiCMS to ensure that AnQiCMS can recognize the correct domain.proxy_set_header X-Real-IP $remote_addr;andproxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;These HTTP headers are used to pass the real IP address of the client, which is crucial for logging, security, and IP identification within AnQiCMS.error_page 404 =200 @AnqiCMS;andlocation / { try_files $uri $uri/index.html @AnqiCMS; }These rules ensure that when Nginx cannot find a static file, it will forward the request to AnQiCMS for processing, which is crucial for AnQiCMS's pseudo-static URLs and single-page application (SPA) routing.
After saving the configuration file, be sure to restart the Nginx service in the aaPanel panel to make the new configuration take effect.
Manually configure Apache reverse proxy in aaPanel (if applicable)
If your aaPanel environment is using Apache as the web server, the configuration method will be different. Make sure Apache'smod_proxyandmod_proxy_httpmodule is enabled.
In aaPanel, you need to find the Apache configuration file for the corresponding domain. Usually, it is under the "Website" -> "Your Domain" -> "Configuration" option, select "Apache Configuration" or edit directlyhttpd.conf.
In the configuration file<VirtualHost>block, you need to add the following or similar rules:
ProxyPass / http://127.0.0.1:8001/
ProxyPassReverse / http://127.0.0.1:8001/
# 可选:如果AnQiCMS有特定路径需要特殊处理
# <Location /system/>
# ProxyPass http://127.0.0.1:8001/system/
# ProxyPassReverse http://127.0.0.1:8001/system/
# </Location>
ProxyPass / http://127.0.0.1:8001/: Forward all requests to the root path/to the AnQiCMS container port 8001.ProxyPassReverse / http://127.0.0.1:8001/Used to adjust the URL in the AnQiCMS response header to ensure that browser redirection or cookie path information is correct, pointing to an external domain rather than an internal IP.
After saving the configuration file, you also need to restart the Apache service in the aaPanel panel to make the configuration take effect.
Complete the initialization settings of AnQiCMS.
No matter whether you are using Nginx or Apache for reverse proxy, once the configuration takes effect, you can access your domain name through the browser (for examplehttp://test.anqicms.com/).At this moment, you should see the initial installation interface of AnQiCMS.Follow the prompts on the interface, fill in the database information, set the administrator account password, and complete the installation of AnQiCMS.
After installation, you can visit您的域名/system/Log in to the AnQiCMS admin interface and start your content creation and operation work.By manually configuring a reverse proxy, you not only solved the problem of failed automated deployment, but also deepened your understanding of the working principles of web workers.
Frequently Asked Questions (FAQ)
1. I have configured reverse proxy, but the domain name still cannot display the AnQiCMS page, how should I troubleshoot?
First, make sure that your AnQiCMS Docker container is running correctly in aaPanel.You can enter the Docker management interface of aaPanel and confirm that the container status is 'Running'.Next, check if the container's port mapping is correct, ensuring that the host port 8001 is indeed mapped to the AnQiCMS port inside the container.proxy_pass(Nginx) orProxyPass(Apache) points tohttp://127.0.0.1:8001The service was restarted without any issues and after modifying the configuration.You can also view the Nginx/Apache error logs of the server and the AnQiCMS container logs to obtain more detailed error information.
2. Why is the target address of the reverse proxy127.0.0.1:8001not the internal IP address of the Docker container?
This is because when the Docker container starts, it will map its internal port (the default listening port of AnQiCMS) to a port on the host machine.127.0.0.1Is the local loopback address of the host machine, and8001Is Docker that exposes the container service to the host machine's port. Therefore, when Nginx or Apache perform reverse proxying on the host machine, it goes through127.0.0.1:8001The actual access is a service running in a Docker container called AnQiCMS.This approach avoids direct dependence on the container's dynamic internal IP address, improving the stability and robustness of the configuration.
3. How should I configure reverse proxy to run multiple AnQiCMS sites on the same server?
Implement multi-site AnQiCMS deployment in aaPanel, first you need to run an independent Docker container for each AnQiCMS instance, and make sure each container maps to a different port on the host machine (for example: the first 8001, the second 8002, and so on).Then, create an independent website for each AnQiCMS site in aaPanel and configure their reverse proxy separately.http://127.0.0.1:8001pointing to the first AnQiCMS,http://127.0.0.1:8002pointing to the second AnQiCMS).After completing these reverse proxy configurations, you can use the powerful "Multi-site Management" feature in the backend of one of the AnQiCMS instances to add and manage all other sites, thereby achieving unified management.