As a website manager who deeply understands 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 with its powerful multi-site management function allows users to manage multiple brands or content branches under a single system architecture, greatly enhancing operational efficiency.However, to fully utilize this advantage, it is often 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-sites.
Apache Reverse Proxy AnQiCMS Multi-site Configuration Method
AnQiCMS (AnQiCMS) is a content management system designed specifically for small and medium-sized enterprises and content operation teams, one of its core highlights being 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, content, and settings.In order to correctly route these different domain requests to the AnQiCMS application instance, and for AnQiCMS to identify and respond to the corresponding site content based on the received domain, we usually need to configure a reverse proxy.Apache is an ideal choice as a widely used web server 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, the HTTP request first reaches the web server (such as Apache).The web server forwards the request to the AnQiCMS application running in the background via reverse proxy.AnQiCMS application receives a request and then parses the request headers ofHostField, based on this domain information, determine which specific site the user is visiting, 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.
The basic principle of Apache reverse proxy
The reverse proxy server is located between the user and the actual web application server.When the 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, its main function is:
It listens to HTTP/HTTPS requests for different domain names.
It forwards all requests to the specific port that the AnQiCMS application is listening on (such as the default 8001 port).It ensures that the original domain information is retained when forwarding requests (i.e., HTTPHostHeader), so that AnQiCMS can correctly identify the target site.
Configuration steps in detail
Configure Apache reverse proxy for AnQiCMS multi-site primarily involves enabling necessary Apache modules, setting up Virtual Host for each site, and configuring core reverse proxy directives.
First, make sure that Apache Web Server is installed on your server and the AnQiCMS application instance is running on some port in the background (for example, by default on127.0.0.1:8001)
Enable Apache module
You need to enable Apache to perform reverse proxyingmod_proxyandmod_proxy_httpModule. It is usually completed by the following command in 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 a separate 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/directory.
This is an example configuration applicable tosite1.comandsite2.comtwo domains, which will be served by the AnQiCMS instance running127.0.0.1:8001:
Withsite1.comCreate a configuration file (for examplesite1.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>
Withsite2.comCreate a configuration file (for examplesite2.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(orsite2.comRedirect the request to127.0.0.1:8001.ProxyPassReverseEnsure that the redirect URL in the AnQiCMS response is correctly modified backsite1.com(orsite2.com)ProxyPreserveHost OnIt is crucial because it ensures the originalHostThe header is passed to AnQiCMS so that AnQiCMS can correctly handle multi-site logic.
If HTTPS support is required, a configuration must be made for each domain.VirtualHostListen on port 443 and add the corresponding SSL certificate configuration, for exampleSSLEngine On/SSLCertificateFileandSSLCertificateKeyFilecommand.
Activate Virtual Host and restart Apache
After configuration, 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 backend configure new site
After configuring reverse proxy in Apache, you still need to log in to the AnQiCMS backend management interface, add the corresponding site in the "Multi-site Management" function. This includes setting the site name, binding to the Apache Virtual Host inServerNameA consistent website address (for examplehttp://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 reminder and **practice
Domain resolution: Make sure that all involved domains (such assite1.com/www.site1.com/site2.cometc.) 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 relevantVirtualHostblock.SSLEngine On/SSLCertificateFileandSSLCertificateKeyFileInstruction, and ensure to listen for HTTPS requests on port 443.
Performance considerations: For high-traffic websites, reverse proxy can also be combined with load balancing technology to distribute requests to multiple AnQiCMS application instances, further enhancing performance and availability.But for most small and medium-sized enterprises, a single AnQiCMS instance combined with a reverse proxy can meet most needs.
Log analysis: