How to match the program port and gateway port when running the website building program in the container

📅 2026-10-11 👁️ 15

When running a website building program in a container, the program port and gateway port do not match. In most cases, it is not that a layer was written incorrectly, but that the three layers were treated as one. The mirror of AnQiCMS is anqicms/anqicms, and it listens to port 8001 by default. The deployment method provides Docker images and one-click deployment with Baota panel and aaPanel. The port relationships under these two paths are the same: program listening port, container mapping port, and gateway external port, each layer has its meaning.

What do the three layer ports refer to?

The first layer is inside the container, which is the address bound by the program itself, also known as the listening port in the configuration. This layer only cares about whether the process can start, and is unrelated to what port is used externally.

The second layer is the runtime mapping of the container, connecting a port on the host to the listening port inside the container. Pay attention to both sides when writing the mapping, confusing the 'host side' and 'container side' order is the most common mistake.

The third layer is the gateway facing outward, which is the port that visitors actually access, usually the 80 and 443 for web services, and is intercepted by the reverse proxy and then transferred to the host port.

Layer Configuration location Typical values The appearance when written incorrectly
Program listening Application run configuration 8001 Container is up but cannot connect, health check failed
Container mapping Run parameters or orchestration file Host port points to container 8001 Works with a different port, or access returns a connection refused
Gateway forwarding Proxy site configuration Forward 80, 443 to host port Direct connection is fine, domain name access is not
External address Site address and redirection table Domain name and protocol Redirected to an intranet address with a port after jumping

Typical manifestation of wrong mapping

Three phenomena can locate to different layers. Normal direct connection with IP and port, abnormal domain name access, the problem is in gateway forwarding; direct connection is also abnormal, first check container mapping; if the mapping is correct but the page cannot be opened, go back to the program listening port and container log.

There is a type that is more concealed: the page can be opened, but the style and interface request returns 404. This is usually because the path forwarding or pseudo-static rules are not connected - the proxy only forwards the home page path, and the static resources and the rewritten addresses are not processed according to the same set of rules. When checking, you should look at the actual forwarding path of the proxy, not the writing in the browser address bar.

The request header that the reverse proxy needs to supplement

After proxying, the program sees the request coming from the forwarder, not the real visitor. To make the application correctly generate absolute addresses, judge the protocol and record the source, the protocol, hostname, and visitor address should be sent together during forwarding, and the application should be configured as a trusted proxy on the application side to avoid directly trusting the potentially forged header values.

The header is not transmitted to the application side, which will cause two typical consequences: first, the https access is judged to be plaintext, and a series of addresses fall back to the wrong protocol, resulting in a mixed content alert; second, the redirection follows the wrong Host, and the user is redirected to an internal address with a port. The 301 redirection table also needs to be written according to the same set of external addresses, otherwise the new and old addresses will bounce back and forth between the two semantic sets.

Four items to check after deployment

First, check the external access: domain, certificate, default page, and one internal page to confirm that the status code and content meet expectations. Then, check the backend entry and login redirect to confirm that the redirected address is still an external address. Third, check the data storage location: whether data is lost during container reconstruction, and whether the static files and attachment directory are mounted on a persistent volume. Fourth, check the backup: AnQiCMS supports data and static file backup and recovery, and the container environment backup should include database files, upload directories, and runtime configurations together, as only leaving the image is not enough because the image does not contain your later changes.

Common questions

Can you directly change the program's listening port to 80?Changing the port within the container merely shifts the mistake to the next layer, while the external side is still terminated by the gateway at 80; the program port remains default, and mapping and forwarding align with it more clearly.

How should ports be divided when multiple sites share a single container?On the program side, it is still a listening port, and multiple sites are distinguished by domain names and site configurations, forwarded by the gateway according to the hostname, and no need to open a port for each site.

What parts need to be changed when the host port changes?Changing the mapping and gateway forwarding at two places is sufficient, the listening port in the application configuration remains unchanged; then check if there are any remnants of the old port notation in the external address and site map.

Related articles

Where is the backend entry of the online experience station, and which capabilities should be verified during the trial?

The information and backend entry path of the experience station are written in the documentation, and the demonstration account is in the README demonstration area. This article provides a 30-minute trial list: content model and columns, AI dialogue and toolset, skill and intent directory, access and approval, included related modules, and explain which conclusions should not be obtained from the experience station.

2026-10-11

The recommended operating environment version on the official website is two levels lower than the minimum version that can run, which level should be configured?

In the same requirement page, there are often two levels of running environment numbers: one level suggests the version supported by the host, and one level is the compatible lower limit that can also run. Often followed by a sentence that these versions have entered the official discontinuation of maintenance, which may expose the site to security risks. This article explains what the two levels of numbers mean, why new sites are configured according to the recommended level, and provides a three-step order to check the language runtime, database, and transmission encryption, as well as which restrictions will disappear after switching to the compiled technology stack.

2026-10-10

Rejected upload returns 413, modify program limit first or modify gateway limit first

When the upload is rejected and returns 413, modify the limit of the gateway layer first, because this status code is returned by the front-end service and the request has not entered the program yet. The sequence is to confirm at which layer the request stops, release the request body limit of the entry layer, and then check the program's own limit. When importing large files in batches, handle them in the same order.

2026-10-10

After replacing the certificate, the page style is missing half, how to clear the http external links in the https page?

After replacing the certificate, the style is missing half, usually due to the residual http resources in the https page being blocked by the browser. The cleaning order is to first locate the residual references, then batch replace them with internal relative addresses or encrypted addresses according to the main text data, template, and configuration, and finally close the jump rules together.

2026-10-10

Why are all the client addresses logged in the log all proxy addresses when a proxy is hung in front of the website?

After the reverse proxy, only the proxy address remains in the log because the connection indeed comes from the proxy. The real source needs to be obtained from the forwarding header, but this header can be forged, and only the section appended by the trusted proxy should be believed when retrieving the value. This article explains the alignment of the order, trust boundaries, and the three steps on the deployment side.

2026-10-11

How will the front-end sorting and push be chaotic when the scheduled publication time zone difference is taken into account

Schedule publishing so that content transitions from pending to official at the specified time. Time zone differences can cause the overall launch time to shift, which may affect the sorting of content by release time on the front end and the timing of link promotions. First, clarify the visibility scope of the three states: pending, official, and recycling bin. Then, unify the time zone standards and verify the release time together during backup and recovery.

2026-10-11

What codes should be returned for deleted articles and hidden columns, and what consequences will there be if they are all compressed into 404?

When deleting content or hiding columns, if the status code is unified to 404, the still existing paths will be read as expired. This article gives the landing points for the four types of semantics: delete, hide, reject, and exception, and explains how the recycling station, draft, and pending publication status within the site correspond to the front-end return, and attaches a list of standards for reference

2026-10-11

The large attachment upload is blocked at 413, why is it not understandable in the browser?

When uploading a large attachment, it is blocked by the gateway and returns 413. Browsers often cannot display the reason because the limit is set before the request enters the application, and the program does not have time to take over. The default limit for this type of nginx is about one megabyte, which can be set by segment according to the site and location. This article explains which segment the limit controls, why the error is difficult to read, and how to check the three types of entry points for attachment upload, batch import, and interface upload.

2026-10-11