How to configure AnQiCMS's Nginx proxy in the Linux command line environment?

Calendar 👁️ 72

As a senior CMS website operation personnel in an enterprise, I know that stable and efficient deployment is the foundation of successful website operation.Under Linux, Nginx, as a high-performance reverse proxy server, is an ideal partner for AnQiCMS, which can effectively improve the speed and security of website access.I will give a detailed introduction on how to configure Nginx under the Linux command line environment to provide a stable and reliable reverse proxy service for AnQiCMS.

Configure AnQiCMS's Nginx proxy in the Linux command-line environment

AnQiCMS (AnQiCMS) is an enterprise-level content management system developed based on the Go language, known for its ease of deployment, fast execution speed, and SEO-friendly features, making it the preferred choice for many small and medium-sized enterprises and content operation teams.When running AnQiCMS on a Linux server, it is usually necessary to use Nginx for reverse proxying so that users can access the website through standard ports 80 or 443 and enjoy the benefits of Nginx such as static file acceleration and SSL encryption.

Preparation: Make sure AnQiCMS is already running on the server

Before configuring Nginx, you need to make sure that the AnQiCMS program has been downloaded and successfully run on your Linux server.Generally, AnQiCMS listens on a specific port, such as the default port 8001.You can start AnQiCMS by following these steps:

First, download the installation package for Linux from the AnQiCMS official website. Extract it to the directory you choose, for example/www/wwwroot/yourdomain.com/In this directory, you will find the AnQiCMS executable file (usually namedanqicms) and onestart.shscript.

To ensure that AnQiCMS can also run automatically after the server restarts, it is recommended to add it to the system's scheduled tasks (Crontab). By runningcrontab -eCommand to open the Crontab editor and then add the following lines:

*/1 * * * * /www/wwwroot/yourdomain.com/start.sh

Be sure to set/www/wwwroot/yourdomain.com/Replace with the actual installation path of AnQiCMS. This command will check every minute if AnQiCMS is running, and if not, it will start it to ensure the continuous availability of the service.After adding, please execute manually once./start.shCommand to ensure that the AnQiCMS service is running.

Configure Nginx reverse proxy

Next, we will configure Nginx to receive user requests and forward them to the port listened to by AnQiCMS. The Nginx configuration file is usually located/etc/nginx/sites-available/or/etc/nginx/conf.d/Under the directory. You need to create a new configuration file for your AnQiCMS site, for exampleyourdomain.com.conf.

Use your favorite text editor (such asviornanoCreate and edit this file:

sudo nano /etc/nginx/sites-available/yourdomain.com.conf

Then, paste the following Nginx configuration code into the file. Modify it according to your actual situation.server_nameandrootcommand.

server
{
    listen 80; # 监听标准的HTTP端口
    # listen 443 ssl http2; # 如果您配置了SSL证书,请取消注释并配置SSL相关指令
    server_name yourdomain.com www.yourdomain.com; # 您的网站域名,可以添加多个

    # 网站根目录,指向AnQiCMS安装目录下的public文件夹
    root /www/wwwroot/yourdomain.com/public;

    # 配置Nginx反向代理,将请求转发给AnQiCMS
    location @AnqiCMS {
        proxy_pass https://en.anqicms.com; # AnQiCMS监听的端口,默认为8001
        proxy_set_header Host $host; # 转发原始请求的Host头
        proxy_set_header X-Real-IP $remote_addr; # 转发客户端的真实IP地址
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 转发客户端代理链的IP地址
        # proxy_set_header X-Forwarded-Proto $scheme; # 如果使用SSL,请取消注释
    }

    # 处理404错误,将所有未找到的请求路由到AnQiCMS处理
    error_page 404 =200 @AnqiCMS;

    # 尝试查找文件,如果找不到则交给AnQiCMS处理
    location / {
       try_files $uri $uri/index.html @AnqiCMS;
    }

    # 设置访问日志,您可以指定日志文件的路径
    access_log /var/log/nginx/yourdomain.com_access.log;
    error_log /var/log/nginx/yourdomain.com_error.log;
}

Configuration details:

  • listen 80;: Nginx listens to the standard port for HTTP requests. If you want to enable HTTPS, you also need to configurelisten 443 ssl http2;and add the SSL certificate path and related configurations.
  • server_name yourdomain.com www.yourdomain.com;: Specify your website domain. When users access these domains, Nginx will apply this configuration.
  • root /www/wwwroot/yourdomain.com/public;This is a very critical step. It points the Nginx website root directory to the AnQiCMS installation directory.publicFolder. AnQiCMS static resources (such as CSS, JS, images, etc.) are usually stored in this directory, Nginx can directly serve these static files without going through the AnQiCMS program.
  • location @AnqiCMS { ... }: This is a named location block used to define how to proxy requests to AnQiCMS.
    • proxy_pass https://en.anqicms.com;: This instruction is the core, it tells Nginx to forward all matched requests to the local@AnqiCMS server.8001Port, which is the address that the AnQiCMS service listens on. If you have modified the running port of AnQiCMS, please make the corresponding modification here.
    • proxy_set_header ...: These instructions are used to pass the original client request header information (such as Host, real IP, etc.) to AnQiCMS, which is crucial for AnQiCMS to obtain the correct client information and log records.
  • error_page 404 =200 @AnqiCMS;When Nginx tries to locate a file but returns a 404 error, it will internally redirect the request to@AnqiCMSThis means that AnQiCMS will be responsible for handling all missing URLs, achieving friendly URL structures and pseudo-static pages.
  • location / { try_files $uri $uri/index.html @AnqiCMS; }: This is the default request handling block. It first attempts to findrootin the directory a file that matches the request URI orindex.htmlIf found, return directly. If the static file does not exist, forward the request to@AnqiCMSName the location block for processing, so that content is dynamically generated by AnQiCMS.

After saving and closing the configuration file, you need to create a symbolic link to activate the configuration file in Nginx'ssites-enableddirectory:

sudo ln -s /etc/nginx/sites-available/yourdomain.com.conf /etc/nginx/sites-enabled/

Check Nginx configuration and restart

Before restarting the Nginx service, make sure to check the syntax of the configuration file to avoid service startup failure:

sudo nginx -t

If the output displayssyntax is okandtest is successfulThis indicates that the configuration is correct. Now, you can reload the Nginx service to apply the new configuration:

sudo systemctl reload nginx
# 或者
sudo service nginx reload

Verify deployment

After completing the Nginx configuration and restarting the service, you can enter your domain name in the browser (for examplehttp://yourdomain.com) Visit the AnQiCMS website. If everything is configured correctly, you will see the AnQiCMS initialization installation interface or the content of the deployed website.

By following these steps, you have successfully configured Nginx reverse proxy for AnQiCMS under the Linux command-line environment, providing a high-performance, highly available access entry for your website.


Frequently Asked Questions (FAQ)

1. Why does the website's CSS, JS, or images fail to load normally after configuring Nginx reverse proxy?

This is usually due to Nginx'srootThe command configuration is incorrect, or the static file path of AnQiCMS does not match the expected Nginx. Please ensure that the Nginx configuration containsrootThe command precisely points to the AnQiCMS installation directory underpublicFolder, for exampleroot /www/wwwroot/yourdomain.com/public;. Nginx will directly serve static resources from this directory.In addition, also check whether the "Global Settings" in AnQiCMS backend is correctly set for "Website Address" and "Template Static File Address", ensuring they are consistent with the domain and path after Nginx proxy.

2. I want to run multiple AnQiCMS sites on the same server, how should I configure Nginx?

AnQiCMS supports multi-site management, you only need one AnQiCMS core program to run multiple sites. At the Nginx level, you need to create an independent site for each AnQiCMS site.serverBlock. Eachserverblock'sserver_nameThe command should correspond to different domain names, and each site shouldrootThe command still points to the same AnQiCMS core programpublicDirectory. AnQiCMS will respond to the requestedHostHeader (Nginx through)proxy_set_header Host $host;Passing) to identify which site is being accessed and to present the corresponding content.In the multi-site management of AnQiCMS backend, you need to add a site configuration for each new domain and ensure that the database and root directory settings are correct.

3. If the default AnQiCMS port 8001 is occupied, how can I solve it?

When AnQiCMS fails to start and prompts that the port is occupied, you can choose to change the listening port of AnQiCMS. This is usually done by editing the AnQiCMS installation directory underconfig.jsonImplement a file. FindportField and change it to another unused port, such as8002. After changing, you need to restart the AnQiCMS service and update the Nginx configuration file accordinglyproxy_passthe port number of the command, for example, toproxy_pass https://en.anqicms.com;is modified toproxy_pass http://127.0.0.1:8002;. After updating the Nginx configuration, don't forget to check the syntax and reload the Nginx service.

Related articles

How to configure reverse proxy for AnQiCMS on Apache server?

AnQiCMS (AnQiCMS) is an enterprise-level content management system developed based on the Go language, known for its high performance, security, and ease of use.It is usually not recommended to expose the application listening port (such as the default 8001) directly to the external network when deploying this type of application.On the contrary, by configuring a reverse proxy such as Apache, a more secure, more stable, and feature-rich access method can be provided for the AnQiCMS website.By configuring Apache to set up reverse proxy, you can achieve many advantages: First

2025-11-06

How to configure Nginx pseudo static rules in AnQiCMS multi-site mode?

AnQi CMS is an efficient and customizable content management system that provides strong support for multi-site operations while meeting diverse content display and management needs.For website operators, the configuration of pseudo-static URLs is a key factor in improving user experience and optimizing search engine rankings.It is particularly important to configure Nginx's pseudo-static rules reasonably in the multi-site mode of AnQi CMS.

2025-11-06

What is the practice of installing multiple AnQiCMS sites on the same server?

As an experienced CMS website operation person, I know how important it is to manage multiple websites efficiently on a single server.The AnQi CMS was designed with the need for multi-site management in mind, providing users with a flexible and powerful solution.The following article will detail the **practice** of installing and managing multiple AnQiCMS sites on the same server.

2025-11-06

How to troubleshoot and fix errors after AnQiCMS installation fails?

As an experienced CMS website operation personnel of a security company, I know that the stable operation of the website and the efficient management of content are the foundation of business success.AnQiCMS with its efficient, concise architecture in Go language and rich enterprise-level features, has won the favor of many users.However, even the most excellent system may encounter unexpected problems during the installation and deployment process.When AnQiCMS installation fails, this may not only delay the progress of going online, but also affect the subsequent operation plan.

2025-11-06

How to set up AnQiCMS to start automatically on Linux server (Crontab)?

As an experienced security CMS website operations personnel, I am well aware of the importance of stable website operation, especially after an unexpected server restart, when the system can automatically restore services, which is crucial for ensuring user access experience and avoiding operation interruption.AnQiCMS (AnQiCMS) is an efficient and concise content management system developed in Go language, with flexible deployment methods, but how to ensure it starts up automatically on Linux servers is a concern for many operators.

2025-11-06

How to perform local development and testing of AnQiCMS in Windows environment?

As an operator who is deeply familiar with the operation of AnQiCMS, I fully understand the importance of sufficient local development and testing before formal launch to ensure the quality of website content, user experience, and system stability.Set up an efficient AnQiCMS local development environment under the Windows environment, which allows you to freely create, edit, publish, and optimize content, while also performing various function tests, thereby greatly improving work efficiency.The following will elaborate on how to carry out local development and testing of AnQiCMS in a Windows environment.###

2025-11-06

How to safely stop or close the AnQiCMS program running on Windows?

As an experienced website operator who deeply understands the operation of security CMS, I am fully aware of the importance of program security, stable operation, and the ability to stop safely when necessary.Whether it is for system maintenance, version upgrade, or daily development and testing, correctly shutting down the AnQiCMS program is a critical step to ensure data integrity and system stability.Under Windows operating system environment, stopping or closing the AnQiCMS program is usually a direct process.Because AnQiCMS is an independent executable file developed based on the Go language

2025-11-06

How do MacOS users install and test AnQiCMS?

As an experienced enterprise CMS website operator, I know the importance of content management systems for enterprises and self-media.AnQiCMS stands out among many CMS systems for its efficiency, flexibility, and security.For MacOS users, the simple deployment process makes local development and testing particularly convenient.Now, I will give you a detailed introduction on how to install and test AnQiCMS on MacOS.

2025-11-06