How to configure Nginx reverse proxy after installing AnQiCMS via command line to access through port 80?

Calendar 👁️ 95

AnQiCMS is an enterprise-level content management system developed based on the Go language, known for its high efficiency, security, and ease of deployment, and has gained the favor of an increasing number of small and medium-sized enterprises and content operation teams. After installing AnQiCMS via the command line in the Linux environment, we usually find that it runs by default in8001This specific port. To allow users to access through a more standardized80port (HTTP) or443Access the website directly via port (HTTPS), and better manage static resources, implement pseudo-static functions, configuring Nginx reverse proxy has become an indispensable step.

This article will serve as your experienced website operations expert, elaborating on how to install AnQiCMS via the command line, and then configure Nginx to set up reverse proxy so that it can pass through80Port access is smooth.


1. Understand the operation mechanism and the necessity of reverse proxy of AnQiCMS.

After you successfully install and start AnQiCMS via the command line, it actually runs as an independent application on the server, usually listening on a non-standard port, such as8001This means that if you enter the server IP address directly in the browser plus8001the port (such ashttp://your_server_ip:8001), you can access the AnQiCMS site.

However, in the actual operation of the website, we hope that users can directly access through the domain name, for examplehttp://www.yourdomain.comPort numbers are not required. This requires the introduction of a 'gatekeeper' - Nginx.Nginx plays the role of a reverse proxy server here.It will listen to the standard80port (or443The port is used for HTTPS requests, when the user initiates a request, Nginx receives the request and then forwards it to a running8001The AnQiCMS backend service on the port, then presenting the content returned by AnQiCMS to the user.

This architecture not only simplifies the user experience, but also has several important advantages:

  • Port standardization:Users do not need to remember specific port numbers.
  • Static resource optimization:Nginx can directly handle images, CSS, JavaScript, and other static files without needing to forward these requests to AnQiCMS, thus greatly reducing the load on AnQiCMS and improving the website's response speed.
  • Enhanced Security:Nginx can provide a layer of security protection in front of AnQiCMS, filtering malicious requests.
  • Load Balancing and Scalability:In theory, Nginx can distribute requests to multiple AnQiCMS instances, implementing load balancing and laying the foundation for future expansion.
  • SEO friendly:Through Nginx, you can implement more flexible pseudo-static (URL rewrite) rules, which is helpful for search engine optimization.

2. Preparatory work

Before starting the Nginx configuration, make sure you have completed the following steps:

  1. AnQiCMS has been installed and is running:Make sure you have successfully installed AnQiCMS according to the official AnQiCMS documentation via the command line on a Linux server, and the AnQiCMS process is running by default,8001The port (or any custom port) is running normally. You canps -ef | grep anqicmscheck its running status with the command.
  2. Nginx is installed:Your Linux server has Nginx Web server installed.
  3. Domain has been resolved:The domain name you plan to use to access AnQiCMS (for examplewww.yourdomain.com) has been correctly resolved to your server IP address.

Step 3: Configure the detailed steps of Nginx reverse proxy

Now, let's configure Nginx step by step to make it able to proxy AnQiCMS service.

1. Find the Nginx configuration file

The main configuration file of Nginx is usually located in/etc/nginx/nginx.conf. To better organize your site configuration, it is recommended to/etc/nginx/sites-available/Create a new configuration file for your AnQiCMS site in the directory, then enable it through a symbolic link/etc/nginx/sites-enabled/In the directory. Or, if your Nginx configuration allows, you can also directly in/etc/nginx/conf.d/Create in the directory.conffile.

We take in/etc/nginx/conf.d/Create a file namedyourdomain.com.conffile as an example.

2. Create or edit the site configuration file

Use your favorite text editor (such asviornano) to open or create the file:

sudo nano /etc/nginx/conf.d/yourdomain.com.conf

Then, paste the following configuration content in. Please replace it according to your actual situation.yourdomain.comand the installation path of AnQiCMS.

`nginx server {

# 监听80端口,用于HTTP访问
listen       80;
# 绑定您的域名,多个域名用空格隔开
server_name www.yourdomain.com yourdomain.com;
# 指定静态文件根目录。AnQiCMS 的静态资源(CSS, JS, 图片)位于其安装目录下的 public 文件夹
# 请将 /www/wwwroot/anqicms.com 替换为您的 AnQiCMS 实际安装路径
root /www/wwwroot/anqicms.com/public;

# 定义一个内部使用的 location 块,用于处理 AnQiCMS 的动态请求
# @AnqiCMS 是一个命名 location,Nginx 内部使用
location @AnqiCMS {
    # 将请求转发到 AnQiCMS 后端服务监听的地址和端口
    # 默认 AnQiCMS 监听在 127.0.0.1:8001
    proxy_pass https://en.anqicms.com;
    # 传递原始请求的 Host 头,确保 AnQiCMS 识别正确的域名
    proxy_set_header   Host             $host;
    # 传递客户端真实 IP 地址,便于 AnQiCMS 后台统计和日志记录
    proxy_set_header   X-Real-IP        $remote_addr;
    # 传递代理链中的所有 IP 地址
    proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
    # 也可以添加其他常用的代理头,例如:
    # proxy_set_header   X-Forwarded-Proto $scheme; # 传递协议类型 (http/https)
}

# 当 Nginx 尝试查找文件时,如果遇到 404 错误,则将请求内部重定向到 @AnqiCMS 块处理
# 这对于 AnQiCMS 的伪静态路由至关重要,它能让 AnQiCMS 处理那些不对应实际静态文件的 URL
error_page 404 =200  @AnqiCMS;

# 根目录请求处理逻辑
location / {
   # 尝试查找请求的 URI 对应的静态文件
   # 尝试查找请求的 URI 对应的目录下的 index.html 文件
   # 如果上述都找不到,则将请求交给

Related articles

How to deploy AnQiCMS on a Linux server without a graphical panel in a command-line environment?

In the wave of digitalization, an efficient and stable content management system (CMS) is an indispensable foundation for both enterprises and individuals to operate websites.AnQiCMS (AnQiCMS) is an enterprise-level CMS developed based on the Go language, which has won good reputation in the industry with its excellent performance, security, and flexible scalability.It is particularly suitable for users who pursue lightweight, efficient, and customizable solutions, whether it is for small and medium-sized enterprises, self-media, or multi-site administrators.

2025-11-06

What are the precautions to be taken when configuring Nginx pseudo-static for AnQiCMS multi-site on the Baota panel?

As an experienced website operations expert, I am well aware of the importance of Nginx pseudo-static configuration for improving user experience and search engine optimization (SEO), especially in a powerful, multi-site management system like AnQiCMS.Static URL rewriting not only makes the URL look more concise and readable, but also makes it more friendly for search engine spiders to crawl and index the content, thus bringing better rankings.

2025-11-06

How to set the root directory and database name of a new site when adding AnQiCMS multi-site via Baota panel to avoid conflicts?

As an experienced website operations expert, I know that how to deploy multiple websites efficiently and without conflict is the key to success.AnQiCMS (AnQiCMS) provides us with great convenience with its excellent multi-site management capabilities.Today, let's delve into how to cleverly set the root directory and database name of a new site when deploying AnQiCMS multi-site with Baota panel, in order to avoid annoying conflicts and ensure that each site can run independently and stably.The strength of AnQi CMS lies in its ability to utilize a simple and efficient system architecture

2025-11-06

How to install and manage multiple AnQiCMS sites on the same Linux server?

HelloAs an experienced website operations expert, I fully understand the importance of efficiently and conveniently utilizing existing resources when managing multiple websites.AnQiCMS with its powerful multi-site management capabilities is born for such needs.It can not only help us reduce operating costs, but also significantly improve management efficiency. Next, I will focus on how to install and manage multiple AnQiCMS sites on the same Linux server?

2025-11-06

How to compile and install the Go language source code of AnQiCMS, what are the required environment dependencies?

As an experienced website operation expert, I am willing to give you a detailed explanation of the steps for compiling and installing the AnQiCMS (AnQiCMS) Go language source code and the required environment dependencies.AnQi CMS, with its excellent genes in Go language, provides high-performance and high-concurrency content management capabilities. For advanced users who want to deeply customize or deploy in specific environments, source code compilation is undoubtedly an ideal choice.

2025-11-06

How to test and run AnQiCMS on Windows system for local development and debugging?

As an experienced website operations expert, I fully understand the importance of setting up a development environment locally.It not only allows you to safely test new features and adjust page layouts, but also accelerates content creation and feature iteration without affecting the online website.Today, let's delve deeply into how to easily set up and test run AnQiCMS on a Windows system, and embark on your local development and debugging journey.

2025-11-06

How to correctly stop or close the AnQiCMS application under Windows?

As an experienced website operations expert, I fully understand that in managing a content system, it is not only important to be proficient in using various functions, but also to maintain and manage the application on a daily basis.AnQiCMS (AnQi CMS) brings us a convenient user experience with its efficient and lightweight features based on the Go language in the Windows environment.However, whether for the need of maintenance, upgrade, or temporary debugging, we need to know how to properly and safely stop or close the AnQiCMS application.

2025-11-06

What is the specific method for installing and testing AnQiCMS under MacOS?

As an experienced website operations expert, I fully understand the importance of an efficient and stable content management system (CMS) for a corporate website.AnQiCMS (AnQiCMS) stands out in the field of small and medium-sized enterprises and content operations with its lightweight and efficient features in the Go language.Today, let's delve into how to easily install and test AnQiCMS on our commonly used MacOS system, so that everyone can better understand and use this excellent CMS.

2025-11-06