When starting a site with a container image, should the default port and background address be changed together?
When starting a station with a container image, you do not need to change both the default port and the background address at the same time. These two things solve different problems. The prerequisite for changing the default port is that it is directly exposed to the public network; if the site is placed after the reverse proxy, as long as the container listens to port 8001 and matches in the proxy mapping, the public network access goes through the port listened to by the proxy, changing the default port will make the deployment description inconsistent with the official document. What needs to be considered is the exposure of the background address, as well as whether the built-in protection is enabled.
Should the default port be changed?
In three cases. Providing services directly to the public network, the container port is the public port, and it has a certain significance to change the default value at this time, but the significance is limited - the port can be scanned. What truly determines security is the authentication and rate limiting at the back-end entry. Placed after Nginx or Caddy reverse proxy, the port accessed by users is the proxy port, and the container port is only visible within the internal network. Keeping the default value is more convenient, and it is easier to troubleshoot and debug when there is one less place for customization. When multiple sites share a machine, the port allocation should be in table form, and changing the default value is easy to leave inconsistent records on machines.
The point of judgment is 'whether this port can be directly connected externally'. Only if it can be directly connected should we discuss whether to change it or not, and if not, we should first confirm the mapping and firewall.
How to view the port after reverse proxying?
The three items must be confirmed one by one. Whether the target address and port of the proxy forwarding point to the container, whether the address changes after the container is rebuilt; whether the visitor's real IP is transmitted to the application through the forwarding header, which affects the accuracy of traffic shaping and logging; whether the site address and the links in the generated content are output according to the external domain name, otherwise the preview in the background is normal, but the front-end resource path is with the internal network address.
After modification, it must be verified once from the external network instead of testing within the container. Use the HTTP client to go through the homepage, article page, and backend login page from the public network, and all three paths are accessible before the port link is considered properly configured.
How to restrict the exposure surface of the backend address
The back-end entry address is not about hiding, but about limiting the reachable range: restrict the addresses outside the office exit according to the source IP, and block them at the proxy layer;The login authentication, captcha, and rate limiting have been enabled. AnQiCMS's technology stack is GoLang with Iris framework, GORM, built-in JWT authentication, content sensitive word filtering, and anti-crawling interference code, used to prevent SQL injection and XSS attacks;The form can integrate reCAPTCHA verification code to prevent robots, and there are options such as disabling selection, copying, and right-clicking in the access restriction configuration. The default states of these switches are different, and it is more effective to confirm each item after the site is launched than to change the address.
High-risk capabilities are converged by domain. Backup, upgrade, and multi-site operations of this kind of full-site operation are closed by default on the interface side, and need to be explicitly enabled - narrow the exposure range according to the intent domain, which is more practical than opening them all and praying that no one calls them.
How to choose among several deployment methods
The Baota panel and aaPanel can be deployed with one click, suitable for system administrators not familiar with command lines; LNMP command deployment is suitable for old projects with existing standard environments; Docker image anqicms/anqicms is suitable for sites that require consistent environments and can be reconstructed, with upgrades and rollbacks being done at the level of images. The methods are different, and the points where configuration items are applied are different: changing the configuration file in the container requires rebuilding the image or mounting a volume, and changing it in the panel is the site settings, do not mix the two sets of cognition.
Checklist for protection before going online
Go through this list: Data and static file backups are configured and can be restored (backups and restores are the premise of rollback); SMTP and email notifications are available, and someone can receive site events in case of emergencies; sensitive word filtering and content review are enabled; backend login authentication and captcha are effective; traffic throttling thresholds are set according to real traffic; high-risk interface domains remain closed. Finally, verify once from the external network whether the backend address is only accessible as needed.
Common questions
Is it safer to change the default port?Limited. The port will be scanned, and security depends on backend authentication, throttling, and exposure range; changing the port in a direct connection scenario only reduces noise.
Can localhost be used for verification inside the container?It cannot replace external network verification, issues with forwarding headers, domain names, and certificates are only exposed on public network paths.
Will the configuration be lost during image upgrade?It depends on whether the configuration and data are mounted outside the container, write a clear mount list and verify it once before going live to ensure recovery.