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

Calendar 👁️ 62

As an experienced AnQiCMS (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 AnQiCMS instances 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.

Understand the default port and configuration mechanism of AnQiCMS

AnQiCMS is a high-efficiency content management system developed based on the Go language. Its default running port is set to8001The core configuration of AnQiCMS, including port settings, is all located in the root directory of the project.config.jsonIn the file. Therefore, modifying the default runtime port of the AnQiCMS instance is essentially editing this configuration file and ensuring that all related services (such as reverse proxies) are synchronized updated.

Positioningconfig.jsonFile

To modify the default port of the AnQiCMS instance, you first need to find the root directory of the AnQiCMS project deployment. In this directory, you will find a file namedconfig.jsonThe file. This file contains the key runtime configuration of the AnQiCMS instance.

For example, if you deployed through Baota panel, your AnQiCMS may be located at/www/wwwroot/yourdomain.com/This path. Although the modification of the container inside is directly deployed through Docker,config.jsonit may be overwritten by the image update, but for the instance that is unpacked directly on the host machine,config.jsonIt is still in the directory after unpacking.

modifyconfig.jsonof the port value

Findconfig.jsonAfter the file, open it with a text editor (such as Vim, Nano, or Baota's file editor). You will see a JSON structure similar to the following:

{
  "app_name": "AnQiCMS",
  "port": "8001",
  // ... 其他配置项
}

Here,you need to find"port": "8001"this line and8001change it to the new port number you want to use,for example8002Make sure to choose a port that is not occupied by other services on the current server to avoid conflicts.

Here is an example of the modified version:

{
  "app_name": "AnQiCMS",
  "port": "8002",
  // ... 其他配置项
}

Saveconfig.jsonfile.

Update the reverse proxy configuration

AnQiCMS usually works with Nginx, Apache, and other web servers to provide services through reverse proxy.After you modify the internal running port of the AnQiCMS instance, be sure to synchronize the configuration of the reverse proxy, otherwise your website will not be accessible.

Nginx reverse proxy configuration example:

If you are using Nginx, please find the Nginx configuration file for the corresponding site (for example, in Baota panel, it is usually located in/www/server/nginx/conf/vhost/yourdomain.com.conf). You can find similar reverse proxy settings in the configuration file:

location @AnqiCMS {
    proxy_pass https://en.anqicms.com; # 这里需要修改为新端口
    proxy_set_header   Host             $host;
    proxy_set_header   X-Real-IP        $remote_addr;
    proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
}

toproxy_pass https://en.anqicms.com;of8001Modify it toconfig.jsonthe new port number you set in8002.

The following is an example after modification:

location @AnqiCMS {
    proxy_pass http://127.0.0.1:8002; # 修改为新端口
    proxy_set_header   Host             $host;
    proxy_set_header   X-Real-IP        $remote_addr;
    proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
}

After saving the Nginx configuration file, you need to reload the Nginx configuration for it to take effect. You can run it in the command line.sudo nginx -s reloadorsystemctl reload nginx. In the Baota panel, you can click "Reload Configuration" on the Nginx service management page.

Apache Reverse Proxy Configuration Example:

If you use Apache, you also need to update the corresponding virtual host configuration file.Find the reverse proxy settings in the configuration file, update the target port to the new port. For example:

ProxyPass        "/" "https://en.anqicms.com/" # 这里需要修改为新端口
ProxyPassReverse "/" "https://en.anqicms.com/" # 这里需要修改为新端口

Change to:

ProxyPass        "/" "http://127.0.0.1:8002/" # 修改为新端口
ProxyPassReverse "/" "http://127.0.0.1:8002/" # 修改为新端口

After saving the Apache configuration file, you need to restart the Apache service to make it effective, for examplesudo systemctl restart apache2.

Panel tools (such as 1Panel, aaPanel, Baota Docker application) port settings:

If you are deploying AnQiCMS through this panel's Docker app store or container management feature, you may need to modify the port in the panel's graphical interface.Generally, there will be port mapping settings when creating or managing AnQiCMS containers.You need to make sure that the container's internal port (usually still 8001) is mapped to the new port you choose on the host machine (for example, 8002).At the same time, the reverse proxy settings of the panel should also point to this new port of the host.Please refer to the official documentation of the panel you are using.

Restart AnQiCMS instance

After modifyingconfig.jsonAfter configuring the reverse proxy, you need to restart the AnQiCMS instance to make the new port settings take effect.

  • Manually run the instance:If AnQiCMS is run directly via the command line or by double-clicking the executable file, you need to stop the currently running AnQiCMS process first (for example, using Linux onkill -9 PIDIn the Windows Task Manager, end the process), then restart the AnQiCMS executable file.
  • Instances run through scripts or service managers:If you usestart.shScript orsystemdto manage the AnQiCMS process using a service manager, please execute the corresponding restart command, for example./stop.shafter./start.shor,systemctl restart anqicms.
  • BaotaGo project deployment:In the Baota panel, find your AnQiCMS project under “Website” -> “Go Project”, click stop first and then click start.
  • Docker container:If it is a Docker container, you may need to stop and restart the container, or rebuild the container (if the port mapping is defined when the container is created).

Check if the new port is effective

After completing the above steps, open your browser and visit your website's domain.If everything goes well, the website should load normally. You can also check if the new port is being listened to using the command line tool, for example, on Linux.netstat -tunlp | grep 8002(Replace 8002 with your new port).

Frequently Asked Questions (FAQ)

What should I do if the website cannot be accessed after changing the port?

First, please check carefullyconfig.jsonIn the fileportDoes the value have been correctly modified and saved? Secondly, confirm that your reverse proxy (Nginx/Apache, etc.) configuration has been synchronized and reloaded/restarted.Finally, usenetstat -tunlp | grep 您的新端口Command to check if the AnQiCMS instance has successfully started on the new port.If the AnQiCMS process is not listening on a new port, check the startup log for more error information.At the same time, also confirm that the firewall has opened the port you have newly set.

Why do I need to use it?config.jsonShould modify the port instead of directly modifying it in the reverse proxy?

config.jsonThe port defined is the port that the AnQiCMS program listens to.The reverse proxy forwards external requests to this internal listening port.If the AnQiCMS program is not running on the port you expect, even if the reverse proxy configuration is correct, you will not be able to establish a connection with AnQiCMS.Therefore, both must be modified and configured synchronously to ensure consistency between internal and external ports.

3. How can I know which ports are available?

On a Linux server, you can usenetstat -tunlpCommand to view all currently listening ports. Avoid using ports occupied by other services, as well as some commonly used system reserved ports (such as 21, 22, 80, 443, etc.), and usually choose non-privileged ports between 1024 and 65535.If you are testing locally, you can also view it through some network tools or the port checking function of the operating system.

Related articles

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

Can AnQiCMS manage the content of different brands in multiple sites统一?

As a website management expert who is deeply familiar with the operation of AnQiCMS, I fully understand your need for unified management of multi-brand content.Today, with the increasing refinement of content marketing, how to efficiently handle content from different brands while maintaining their independence and maximizing operational efficiency is a common challenge faced by many enterprises.The multi-site management function of AnQi CMS is exactly for solving such problems, but its interpretation of 'unified management' requires us to conduct a more detailed analysis.

2025-11-06

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

As a senior security CMS website operator, 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.AnQi CMS, developed in Go language, provides us with a powerful content publishing and management platform with its high performance and flexible multi-site support.Today, I will give a detailed introduction on 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.### Deep Understanding

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