Hello, as a website operator who is deeply familiar with the operation of AnQiCMS, I know the importance of efficient content management for both enterprises and individual operators.AnQiCMS with its powerful multi-site management capabilities, provides great convenience to users.Today, I will elaborate on how to implement multi-site deployment of AnQiCMS through reverse proxy technology, helping you manage multiple brands or content branches more flexibly.
Understanding AnQiCMS multi-site deployment and reverse proxy
AnQiCMS was designed from the outset with the need for multi-site management in mind, it allows users toan AnQiCMS instanceCreate and independently manage multiple websites. This means you do not need to install a set of AnQiCMS programs separately for each website, thereby greatly simplifying the deployment and maintenance work.To allow these websites managed by the same AnQiCMS instance to access the outside world through different domain names, reverse proxy technology is an indispensable bridge.
The reverse proxy server is located between the user and your AnQiCMS application. When the user accessessite1.comorsite2.comAt the time, the request first arrives at the reverse proxy server. The reverse proxy, based on the predefined rules, forwards these requests to the AnQiCMS backend service (usually an intranet IP and port), and returns the content of the AnQiCMS response to the user.This method not only achieves the purpose of accessing a single backend application through multiple domains, but also brings additional advantages such as security, load balancing, and caching.
Preparation work before deployment
Before starting to configure the reverse proxy to implement AnQiCMS multi-site deployment, you need to ensure the following points:
First, AnQiCMS has been successfully installed on your server, whether through Docker containers (such as 1Panel, aaPanel, or the Docker function of Baota Panel) or manually deployed in the Linux environment. The key point is that the AnQiCMS service itself is already running on a specific port, such as the default one.8001on the port.
Secondly, you own all the domain names needed for the sites to be deployed, and these domains have been correctly resolved to your server IP address.
Finally, the web server you chose (such as Nginx or Apache) has been installed and has the reverse proxy module.
The core step: Implementing AnQiCMS multi-site through reverse proxy
The core process of the multi-site deployment can be divided into two main parts: the reverse proxy configuration of the web server, as well as the addition of multi-sites in the AnQiCMS backend.
1. Configure the web server reverse proxy
Assuming your AnQiCMS instance is running on the server's127.0.0.1:8001. For each site you want to access via a separate domain, you need to configure a reverse proxy rule in the web server.
For example, you can add the following configuration to the Nginx site configuration file.For your main site (i.e., the first domain you bound when installing AnQiCMS), the configuration will directly point to the service port of AnQiCMS.
server
{
listen 80;
server_name your-main-site.com; # 您的主域名
root /www/wwwroot/anqicms.com/public; # AnQiCMS的公共文件目录,可选,通常与proxy_pass配合使用
location @AnqiCMS {
proxy_pass http://127.0.0.1:8001; # AnQiCMS的运行地址和端口
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;
}
access_log access.log;
}
For the auxiliary sites you want to add (such assub.your-main-site.com),You need to create a new Nginxserverblock, and also reverse proxy its requests tothe same port of the AnQiCMS instance. AnQiCMS will identify which site is requesting content based on the HTTP request header.Hostfield to identify which site is making the content request.
server
{
listen 80;
server_name sub.your-main-site.com; # 您的辅助站点域名
root /www/wwwroot/anqicms.com/public; # AnQiCMS的公共文件目录,可选
location @AnqiCMS {
proxy_pass http://127.0.0.1:8001; # 同样指向AnQiCMS的运行地址和端口
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;
}
access_log sub_access.log;
}
After the configuration is complete, please make sure to restart the Nginx service to make the changes take effect. If you are using Apache as a web server, the configuration method is similar, mainly throughProxyPassandProxyPassReverseImplement the command.
2. Add a new site in the AnQiCMS backend.
When the reverse proxy configuration of the web server is ready, the next step is to create and configure a new site in the AnQiCMS management backend.
First, log in to the admin interface of your AnQiCMS main site.In the left menu, find and click the "Multi-site Management" feature.Here, you will see a 'Add New Site' button, click it to start the creation process of a new site.
In the pop-up interface, you need to fill in the detailed information of the new site:
- Site name: This is a friendly name used to distinguish different sites in the background, please fill it according to the actual situation.
- Site root directoryThis item is used to independently store cache, templates, and other data for new sites. According to the convention, it is recommended to start with
/app/and follow it with a domain name that has replaced the dot with.an underscore_), for example/app/sub_your_main_site_comEnsure that the root directory name of each site is unique to avoid data confusion. - website address: Enter the complete URL of the new site, for example
http://sub.your-main-site.com. AnQiCMS will use this as the basis for generating links. - Administrator account password: Set up independent backend administration account and password for new site.
- Database name: It is also recommended to use a domain name replaced with a point (
.an underscore_) as the database name, for examplesub_your_main_site_com. This will create an independent database for the new site, ensuring data isolation. - Duplicate database informationIf your AnQiCMS is installed with Docker and has full database management permissions, you can usually choose to 'reuse the default database account information', saving the trouble of re-entering database credentials.
- Select the template to use: Choose an appropriate template for the new site.
After filling in all the necessary information, click the "OK" button to complete the creation of the new site. At this point, AnQiCMS has already prepared the data and configuration for this new site.
Website Usage and Verification
After completing the reverse proxy and AnQiCMS backend site configuration of the web server, the new site can be accessed directly through its independent domain name. You can enter the URL of the new site in the browser (for examplehttp://sub.your-main-site.com/),and perform the initial installation (if required by AnQiCMS), or directly access the background management interface (for examplehttp://sub.your-main-site.com/system/) to manage its content.
Through the AnQiCMS multi-site management list, you can conveniently 'access the backend', and directly jump to the management interface of the new site.
Conclusion
By using reverse proxy technology, combined with the powerful multi-site management function of AnQiCMS, you can easily implement a high-performance, unified management multi-site cluster in Go language.This deployment method is not only efficient and secure, but also highly scalable, meeting the content needs of small and medium-sized enterprises, self-media operators, and multi-brand management users, and helping your online business to thrive.
Frequently Asked Questions (FAQ)
Q1: How to configure reverse proxy for a new domain after installing AnQiCMS via Docker on the Baota panel?
A1:In the Baota panel, you can click on the left menu item "Website", then select "Reverse Proxy", and click "Add Reverse Proxy". In the pop-up window, fill in the domain name of the new site, and the target URL should be filled with the intranet address and port of your AnQiCMS Docker container, for examplehttp://127.0.0.1:8001After completing the reverse proxy settings, go to the "Multi-site Management" section of the AnQiCMS backend to add the new site.
Q2: Why does the AnQiCMS backend require me to fill in the 'site root directory' and 'database name' when creating a new site, and what are these used for?
A2:Although all sites are served by the same AnQiCMS program instance, AnQiCMS creates an independent storage space for each site to maintain data and configuration independence.The site root directory is used to store the cache files, uploaded static resources (such as images), and some template configurations of the site.The database name is used to create an independent database table (or even an independent database) for the site, ensuring that the content, users, settings, and other data of each site are isolated from each other and do not affect each other.This will not affect the normal operation of other sites even if you perform operations on a site.
Q3: Can I proxy requests from different domain names to different AnQiCMS instances? For examplesite1.comproxy to127.0.0.1:8001 instance,site2.comproxy to127.0.0.1:8002 instance?
A3:Can be. The reverse proxy itself supports forwarding requests from different domain names to completely independent backend services.If you want each site to run an independent AnQiCMS instance (for example, for higher isolation or resource allocation), you just need to configure a different running port for each AnQiCMS instance and direct different domain names to the corresponding AnQiCMS instance ports in the reverse proxy configuration of the web server.However, it is important to note that the multi-site management function built into AnQiCMS is designed toone instanceManage multiple sites to save resources and simplify management, so you can weigh and choose the most suitable deployment method according to your specific needs.