Hello everyone, as a website operator who is well-versed in the operation of AnQiCMS, I deeply understand 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 achieve the multi-site deployment of AnQiCMS through reverse proxy technology, helping you to manage multiple brands or content branches more flexibly.

Understand AnQiCMS multi-site deployment and reverse proxy

AnQiCMS was designed with the need for multi-site management in mind, it allows users toa single AnQiCMS instanceCreate and independently manage multiple websites.This means you do not need to install a separate AnQiCMS program for each website, thus greatly simplifying the deployment and maintenance work.To enable these websites managed by the same AnQiCMS instance to access externally through different domain names, reverse proxy technology is an indispensable bridge.

Reverse proxy server is located between the user and your AnQiCMS application. When the user accessessite1.comorsite2.comWhen, the request first reaches the reverse proxy server.Reverse proxy forwards these requests to the backend service running AnQiCMS according to the preset rules (usually an internal 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 domain names, but also brings additional advantages such as security, load balancing, and caching.

Preparation Before Deployment

Before starting to configure reverse proxy to implement AnQiCMS multi-site deployment, you need to ensure the following points:

Firstly, AnQiCMS has been successfully installed on your server, whether through Docker containers (such as 1Panel, aaPanel, or the Docker feature of Baota Panel) or manually deployed in the Linux environment. The key is that the AnQiCMS service itself is running on a specific port, such as the default port of8001port.

Next, you have all the necessary domain names for the site deployment, and these domains have all been correctly resolved to your server IP address.

Finally, the web server (such as Nginx or Apache) you have chosen has been installed and has the reverse proxy module.

核心步骤:通过反向代理实现AnQiCMS多站点 (English)

The core process of the entire 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 server127.0.0.1:8001For each site you want to access through a separate domain, you need to configure a reverse proxy rule in the web server.

For example, using Nginx, you can add the following configuration to the Nginx site configuration file.For your main site (i.e., the first domain bound when you install AnQiCMS), the configuration will directly point to the AnQiCMS service port.

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 (for examplesub.your-main-site.com),You need to create a new Nginx for itserverblock, 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.

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 configuration, please make sure to restart the Nginx service to make the changes take effect. If you are using Apache as the web server, the configuration method is similar, mainly throughProxyPassandProxyPassReverseInstructions to implement.

2. Add a new site in 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 backend management 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 process of creating 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 Directory:This item is used for independently storing the cache, template and other data of a new site. According to the convention, it is recommended to start with/app/, followed by a domain name with dots replaced by._ (_) as 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 full URL of the new site, for examplehttp://sub.your-main-site.com。AnQiCMS will use this as the basis for generating links.
  • Administrator account passwordSet up a separate admin account and password for the new site.
  • Database name:It is also recommended to use a domain name replaced with dots("._ (_) as the database name, for examplesub_your_main_site_comThis will create a separate database for the new site, ensuring data isolation.
  • Database information reuseIf your AnQiCMS is installed using Docker and you have full database management permissions, you can usually choose to 'Reuse default database account information' to avoid the trouble of repeatedly entering database credentials.
  • Select the template to useSelect an appropriate template for the new site.

After filling in all 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 configuration of the Web server reverse proxy and AnQiCMS backend site, 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 multi-site management list of AnQiCMS, you can conveniently "access the backend" and directly jump to the management interface of the new site.

Concluding remarks

By using reverse proxy technology, combined with AnQiCMS's powerful multi-site management feature, 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, capable of meeting the content needs of small and medium-sized enterprises, self-media operators, and multi-brand management users, and helping your online business thrive.


Common Questions and Answers (FAQ)

Q1: I have installed AnQiCMS through Docker on the Baota panel, how can I configure reverse proxy for the new domain?

A1:In the Baota panel, you can click on the 'Website' in the left menu, 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 internal network 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 in the AnQiCMS backend to add the new site.

Q2: Why does AnQiCMS backend require me to fill in 'Site Root Directory' and 'Database Name' when creating a new site? These are for what purpose?

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. “Database name” is to create an independent database table (or directly 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.So, even if you perform operations on a certain site, it will not affect the normal operation of other sites.

Q3: Can I proxy requests from different domain names to different AnQiCMS instances? For examplesite1.comproxy to127.0.0.1:8001 instances,site2.comproxy to127.0.0.1:8002 instances?

A3:Can be.Reverse proxy inherently supports forwarding requests to completely independent backend services for different domains.If you want each site to run an independent AnQiCMS instance (for example, for higher isolation or resource allocation), you only need to configure a different running port for each AnQiCMS instance and in the reverse proxy configuration of the web server, direct different domain names to the corresponding AnQiCMS instance ports.an instanceManage multiple sites to save resources and simplify management, so you can weigh the choice of the most suitable deployment method according to your specific needs.