As a website manager who is well-versed in the operation of AnQiCMS, I fully understand the importance of efficient and scalable content management for enterprises, especially when facing the needs of multi-site operations.AnQiCMS relies on its powerful multi-site management function, allowing users to manage multiple brands or content branches under a single system architecture, greatly enhancing operational efficiency.However, to fully utilize this advantage, often it is necessary to rely on reverse proxy technology at the server level, where Apache is the preferred solution for many users.
This article will elaborate on how to configure Apache as a reverse proxy to achieve stable and efficient operation of AnQiCMS multi-site.
Apache Reverse Proxy AnQiCMS Multi-site Configuration Method
The AnQiCMS (AnQiCMS) is a content management system designed specifically for small and medium-sized enterprises and content operation teams. One of its core highlights is the native support for multiple sites.This means that users can create and manage multiple independent websites within an AnQiCMS application instance, each with its own domain name, content, and settings.In order to correctly route these different domain name requests to the AnQiCMS application instance, and for AnQiCMS to identify and respond to the corresponding site content based on the received domain name, we usually need to configure a reverse proxy.Apache is widely used as a web server and is an ideal choice to achieve this goal.
AnQiCMS Multi-site Management Mechanism Overview
The multi-site feature of AnQiCMS allows you to host multiple independent websites in a single AnQiCMS deployment.When a user accesses a website through its domain name, the HTTP request first reaches the web server (for example, Apache).The web server forwards requests to the AnQiCMS application running in the background via reverse proxy.HostField, judge which specific site the user is visiting according to this domain name information, and load the corresponding website data and template for rendering.This mechanism greatly simplifies the complexity of multi-site deployment and maintenance, avoiding the need to deploy a separate AnQiCMS application instance for each site.
Apache Reverse Proxy Basic Principles
The reverse proxy server is located between the user and the actual Web application server.When a user initiates a request, the request is first sent to the reverse proxy server.Reverse proxy servers forward requests to one or more backend web application servers according to the configured rules (such as domain names) and return the responses from the application servers to the users.
For AnQiCMS multi-site scenarios, Apache acts as a reverse proxy with the main function being:
It listens to HTTP/HTTPS requests from different domain names.It forwards all requests to the AnQiCMS application listening on a specific port (such as the default 8001 port).HostHeader), so that AnQiCMS can correctly identify the target site.
Detailed configuration steps
Configure Apache reverse proxy for AnQiCMS multi-site mainly involves enabling necessary Apache modules, setting up Virtual Host for each site, and configuring core reverse proxy directives.
First, make sure that the Apache Web server is installed on your server and that the AnQiCMS application instance is running on some port in the background (for example, the default port is127.0.0.1:8001).
Enable Apache Module
You need to enable Apache to perform reverse proxyingmod_proxyandmod_proxy_httpModule. Usually, it can be completed by the following commands on most Linux distributions:
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo systemctl restart apache2 # 或 sudo service apache2 restart
Create or modify Virtual Host configuration
Next, you need to create an independent Virtual Host configuration file for each domain managed by AnQiCMS, or modify the existing configuration file. These files are usually located/etc/apache2/sites-available/or/etc/httpd/conf.d/the directory.
The following is an example configuration, applicable tosite1.comandsite2.comtwo domains, which will both be served by the127.0.0.1:8001AnQiCMS instance running on
response forsite1.comCreate a configuration file (for example)site1.com.conf):
<VirtualHost *:80>
ServerName site1.com
ServerAlias www.site1.com
# 可选:设置日志路径
ErrorLog ${APACHE_LOG_DIR}/site1.com_error.log
CustomLog ${APACHE_LOG_DIR}/site1.com_access.log combined
# 启用反向代理模块
ProxyRequests Off
# 保持原始Host头,AnQiCMS根据此头判断站点
ProxyPreserveHost On
# 将所有对site1.com的请求转发到AnQiCMS的8001端口
ProxyPass / http://127.0.0.1:8001/
ProxyPassReverse / http://127.0.0.1:8001/
<Location />
# 允许所有请求通过代理,可根据需求进行更精细的访问控制
Require all granted
</Location>
</VirtualHost>
response forsite2.comCreate a configuration file (for example)site2.com.conf):
<VirtualHost *:80>
ServerName site2.com
ServerAlias www.site2.com
ErrorLog ${APACHE_LOG_DIR}/site2.com_error.log
CustomLog ${APACHE_LOG_DIR}/site2.com_access.log combined
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://172.0.0.1:8001/
ProxyPassReverse / http://172.0.0.1:8001/
<Location />
Require all granted
</Location>
</VirtualHost>
Please note,ProxyPass / http://127.0.0.1:8001/the command will route all incomingsite1.com(or}site2.comThe request is forwarded to127.0.0.1:8001.ProxyPassReverseEnsure that the redirect URL in the AnQiCMS response is correctly modified back tosite1.com(or}site2.com).ProxyPreserveHost OnIt is crucial because it ensures that the originalHostThe header is passed to AnQiCMS, allowing AnQiCMS to correctly handle multi-site logic.
If HTTPS support is required, a configuration needs to be set up for each domain.VirtualHostListen on port 443 and add the corresponding SSL certificate configuration, for example,SSLEngine On/SSLCertificateFileandSSLCertificateKeyFileCommand.
Activate Virtual Host and restart Apache
Configuration completed, you need to activate these Virtual Hosts and restart the Apache service to make the changes take effect.
sudo a2ensite site1.com.conf
sudo a2ensite site2.com.conf
sudo systemctl restart apache2 # 或 sudo service apache2 restart
AnQiCMS background configuration of a new site
After configuring reverse proxy in Apache, you need to log in to the AnQiCMS backend management interface, and add the corresponding site in the "Multi-site Management" feature. This includes setting the site name, binding to the Apache Virtual Host inServerNameA consistent website address (e.g.,http://site1.com), and specify an independent site root directory and database name for the new site so that AnQiCMS can store and manage its content.
Important hints and **practice
Domain resolution: Ensure that all involved domain names (such assite1.com/www.site1.com/site2.com) have their DNS records correctly pointing to your server IP address.
SSL/TLS configuration: It is strongly recommended to configure HTTPS for all sites. In Apache, you need to add in the respectiveVirtualHostblock.SSLEngine On/SSLCertificateFileandSSLCertificateKeyFileInstructions, and ensure that HTTPS requests are listened to on port 443.
Performance consideration: For high-traffic websites, reverse proxy can be combined with load balancing technology to distribute requests to multiple AnQiCMS application instances, further improving performance and availability.For most small and medium-sized enterprises, a single AnQiCMS instance combined with reverse proxy is already able to meet most needs.
Log analysis: