How to configure the pseudo-static rules for Nginx reverse proxy for AnQiCMS multi-site?

Calendar 👁️ 58

As a senior CMS website operation personnel of a well-known security company, I am well aware that the efficient operation of a content management system is crucial for website operators, especially when it comes to multi-site management and SEO optimization.The AnQi CMS, developed in Go language with its high performance and flexible multi-site support, provides us with a powerful content publishing and management platform.Today, I will introduce in detail how to configure pseudo-static rules for multi-site AnQiCMS in the Nginx environment, ensuring that your website can enjoy optimized URL structure and smooth access experience.

Deeply understand the AnQiCMS multi-site and pseudo-static mechanism

Before configuring Nginx's rewrite rules, we first need to understand the underlying mechanism of AnQiCMS handling multiple sites and rewrite requests.AnQiCMS as a modern content management system, its "multi-site management" feature allows us to create and manage multiple independent websites under a single AnQiCMS application instance.This means that, regardless of how many sites there are, there may only be one AnQiCMS application running in the backend, which identifies incoming requests byHostDetermine which site the user is visiting and load the corresponding site's data and content accordingly.

As for "pseudo-static", AnQiCMS has built-in multiple pseudo-static rule configurations, such as number patterns, model naming patterns, category naming patterns, etc. These rules define the URL structure displayed in the browser for website content (such as articles, categories, single pages, etc.). For example, the URL of an article may start from/archive.php?id=123Made more readable and SEO-friendly/news/article-123.htmlThese pseudo-static rules are parsed and handled by the AnQiCMS application itself.The role played by Nginx here is not to perform complex URL rewriting, but to forward all requests that cannot be directly matched to static files (such as images, CSS, JS) to the backend AnQiCMS application, where AnQiCMS will handle the subsequent URL parsing and content distribution.

Basic Nginx Reverse Proxy Configuration

Nginx is an ideal choice for deploying AnQiCMS as a high-performance web server and reverse proxy server.The core function of reverse proxy is to forward the client's requests to the internal application server and return the responses from the application server to the client.For AnQiCMS, it is usually deployed on some internal port (such as the default 8001), while Nginx listens to the standard HTTP/HTTPS ports (such as 80/443), responsible for receiving external requests and forwarding them to AnQiCMS.

A basic Nginx reverse proxy configuration snippet usually includesproxy_passCommand used to specify the address and port of the AnQiCMS application, as well asproxy_set_headerCommand used to correctly transfer the original request header information of the client (especiallyHostThe header and client IP address are passed to AnQiCMS, which is crucial for AnQiCMS to identify the correct site and record the user's IP address.

This is a basic Nginx for a single AnQiCMS instance regardless of how many sites it manageslocationConfiguration example, usually placed in your Nginx site configuration fileserverWithin block:

location @AnqiCMS {
    proxy_pass https://en.anqicms.com; # 请替换为AnQiCMS实际运行的IP和端口
    proxy_set_header   Host             $host;
    proxy_set_header   X-Real-IP        $remote_addr;
    proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
    # 更多HTTP头,例如:
    proxy_set_header   X-Forwarded-Proto $scheme;
}

error_page 404 =200 @AnqiCMS; # 当Nginx找不到文件时,将请求转发给AnQiCMS处理

location / {
   try_files $uri $uri/index.html @AnqiCMS; # 尝试查找静态文件,否则转发给AnQiCMS
}

This configuration means that Nginx first tries to find the requested URI's corresponding static file in the root directory of the website (usually AnQiCMS'spublicdirectory) orindex.htmlIf found, directly return the static resource. If not found, forward the request to named@AnqiCMSinternallocationblock, which will proxy the request tohttps://en.anqicms.com(Your AnQiCMS application listens to the address and port).error_page 404 =200 @AnqiCMS;Ensure that even 404 errors considered at the Nginx level are also forwarded to AnQiCMS for processing so that AnQiCMS can handle its internal URL routing or display a custom 404 page.

Configure AnQiCMS backend multi-site

Before configuring multiple site pseudo-static in Nginx, you need to complete the creation of the new site in the AnQiCMS backend.The design of AnQi CMS allows a single application instance to manage multiple independent sites, which greatly simplifies operations.

In the AnQiCMS background that has been installed and running, new sites are usually added through the 'Multi-site Management' feature. During the process of adding a new site, you need to specify the following key information:

  • Site name: It is used to identify your site.
  • Site root directory: This path is used by AnQiCMS to store independent data of this site (such as cache, uploaded files, etc.). It is recommended to use/app/Start (if it is a Docker environment), add the domain name with dots replaced by underscores, for example/app/dev_anqicms_comEnsure data isolation between different sites.
  • website address:You will use the domain name to access the new site, for examplehttp://dev.anqicms.com. AnQiCMS will match requests based on this domain.
  • Database nameEach site should have an independent database, and it is also recommended to use domain names with underscores instead of dots, for exampledev_anqicms_com.
  • Administrator account passwordSet up independent backend management credentials for the new site.
  • Template: Choose the template suitable for the new site.

After completing these configurations, AnQiCMS is ready to respond to requests from the new site.

Nginx reverse proxy AnQiCMS multi-site pseudo-static rules configuration

For the multi-site feature of AnQiCMS, Nginx configuration does not need to write different pseudo-static rules for each site because AnQiCMS itself willHostThe header identifies different sites. Nginx only needs to configure a separate one for each domain.serverBlock it and forward all requests to the same AnQiCMS application instance.

Here is a complete example of a Nginx multi-site configuration, assuming your AnQiCMS application is running inhttps://en.anqicms.comand you havewww.anqicms.comanddev.anqicms.comTwo sites:

`nginx

Define the upstream server for AnQiCMS application

upstream anqicms_backend {

server 127.0.0.1:8001; # AnQiCMS应用监听的地址和端口
keepalive 64;

}

AnQiCMS public proxy configuration, can be reused

location @AnqiCMS_proxy {

proxy_pass http://anqicms_backend;
proxy_set_header   Host             $host;
proxy_set_header   X-Real-IP        $remote_addr;
proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
proxy_set_header   X-Forwarded-Proto $scheme;
proxy_redirect     off;
proxy_buffering    off;
proxy_http_version 1.1;
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;

}

The first site: www.anqicms.com

server {

listen 80;
server_name www.anqicms.com;
root /www/wwwroot/anqicms/public; # AnQiCMS应用存放静态资源的public目录

#

Related articles

How to modify the default port of an AnQiCMS instance specifically?

As an experienced AnQiCMS website operations personnel, I know that every detail of the system configuration is related to the stability and security of the website.Modifying the default port of the AnQiCMS instance is a common requirement in website deployment and security optimization, especially when you need to run multiple AnQiCMS instances on the same server or avoid using the default port for security reasons.Below, I will explain to you in detail how to operate.

2025-11-06

How to deploy multiple CMS instances on a single AnQiCMS server?

As an experienced website operator proficient in AnQiCMS, I fully understand the importance of efficiently and flexibly managing multiple websites under the growing business demands.Sometimes, this means we need to deploy multiple independent CMS instances on a single server to meet different project requirements or higher isolation requirements.AnQiCMS is an enterprise-level content management system based on the Go language, with its lightweight and efficient characteristics, it is very suitable for such deployment scenarios.

2025-11-06

How does the multi-site function of AnQiCMS support cross-site data sharing?

As an experienced website operator familiar with AnQiCMS, I am well aware of the importance of multi-site management for modern content operations.It not only helps enterprises efficiently manage multiple brands or product lines, but also enables effective circulation of resources and content between different sites.AnQiCMS provides strong and flexible support in this field, especially in cross-site data sharing, demonstrating its unique advantages.Explore the multi-site architecture of AnQiCMS AnQiCMS is positioned to serve small and medium-sized enterprises, self-media operators, and multi-site management needs users

2025-11-06

How can the multi-site management of AnQiCMS reduce repetitive work?

As an experienced CMS website operation personnel of an enterprise, I know that many enterprises and individuals often need to manage more than one website in today's complex network environment.Whether it is for different brands, product lines, or regional markets, multilingual promotion, and multi-site operations have become the norm.However, if each website is deployed and managed independently, it would undoubtedly bring about a huge amount of redundant work and operational burden.

2025-11-06

What is the configuration method for Apache reverse proxy for AnQiCMS multi-site?

As a website manager who deeply understands the operation of AnQiCMS, I highly appreciate 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.

2025-11-06

Does AnQiCMS support independent SEO optimization for each site in multi-site mode?

HelloAs an experienced website operator familiar with AnQiCMS, I can clearly tell you that AnQiCMS fully supports independent SEO optimization for each site in multi-site mode.This is part of the core design concept of AnQiCMS, aiming to provide an efficient and flexible content management and promotion solution for enterprises with multiple brands, sub-sites, or content branches.

2025-11-06

How can AnQiCMS multilingual support be applied to multi-site deployment?

As an experienced CMS website operation personnel in the security industry, I fully understand the importance of multilingual and multi-site strategies in expanding business and enhancing user experience in today's increasingly globalized market.AnQi CMS provides a powerful and flexible solution to achieve this goal with its high efficiency and customizable features.The following will elaborate on how Anqi CMS's multilingual support plays a role in multi-site deployment.

2025-11-06

What is the minimum version requirement for installing AnQiCMS via Docker on Baota panel?

As an experienced security CMS operator, I know the importance of a stable and efficient content management system for a corporate website.Among many deployment solutions, Baota panel combines Docker container technology to provide a convenient and flexible installation method for Anqi CMS.However, it is crucial to clarify the minimum version requirements before proceeding with the installation, as this can effectively avoid potential compatibility issues and ensure smooth system operation.

2025-11-06