How to configure reverse proxy and domain access since the program listens by default on port 8001
AnQiCMS listens on the default port 8001, when the domain name is accessed for formal launch, it should not carry this port number. The standard approach is to have the program listen internally, with the Web server doing reverse proxying externally: users access 80 or 443, and the proxy layer forwards it to the local port 8001, with the HTTPS certificate also unified at the proxy layer. In this way, port exposure, encryption termination, and static acceleration are all contained in one place, keeping the program itself simple.
Default port and external port分工
8001 is the internal listening port of the program, its existence is to avoid competing with other services on the machine for 80/443; the external port is used by the Web server (Nginx, Apache, or the built-in proxy service of the panel). After confirming the division of labor, the configuration has a clear main line: the firewall only allows 80 and 443, limiting 8001 to only be accessible within the local machine or the internal network, avoiding users bypassing the proxy to directly connect to the port, and also reducing the exposed surface.
Access verification should be done in layers: first, confirm that the local request on the server machine has a response at port 8001, then confirm that the proxy forwarding rules are hit, and finally access from the outside using a domain name. Each section corresponds to a type of fault, and it is not easy to misjudge in sequence.
Reverse proxy needs to forward more than just ports.
The proxy rules not only forward the request to 8001 but also include three sets of information: the real client protocol (X-Forwarded-Proto), the real access domain (Host header), and the visitor IP pass-through header. If the protocol header is missing, the links generated by the background will jump between http and https; if Host is missing, the program cannot determine which domain this request belongs to in the multi-site scenario; if IP pass-through is missing, the logs will all be the address of the proxy itself, and risk control and statistics will be distorted.
In the site configuration of the reverse proxy software itself, fill in the above headers one by one, which is more priority than adjusting the forwarding timeout parameters.
HTTPS termination layer and 301 redirect
The certificate is installed in the proxy layer, allowing the decryption of 443 to occur on the web server, plain text or internal encryption is optional for the internal network to 8001.After installing the certificate, URL convergence should be performed: each address of the http version, as well as the direct connection addresses with :8001 in history, should be redirected to the final https standard domain through 301 redirection.This step can be configured to set up redirect rules in the AnQiCMS backend using 301 redirect management,配合 pseudo-static rules to unify the address form, the unified standard address received by search engines, and there is no need to rely on page-level补救 such as canonical.
When convergence is not done thoroughly, common symptoms are that the search results mix the same site with http, https, and port addresses, and after clicking, there are still jump links. Just go back and check whether the 301 rules at the proxy layer and backend are duplicated or conflicting.
Configuration points under Baota and Docker paths
The deployment method determines where these configurations are written. When using the Baota panel one-click deployment (or the international version aaPanel), the reverse proxy and certificate are completed in the site settings of the panel: create a site, add proxy rules pointing to 8001, one-click apply for a certificate, enable mandatory HTTPS, the entire process does not touch the listening configuration of the program itself, command line deployment under the LNMP environment is also the same point, just write the Nginx configuration.
When taking the Docker route, after starting the container with the official image anqicms/anqicms, map port 8001 to the host's internal port, and place an Nginx or Traefik container in front to take over.80⁄443With the certificate. The key point is not to publish the container port directly to the public network firewall outside, and ensure that the forwarding header configuration of the proxy container is consistent with the above.
No matter which path, make a backup of the current data before you start, you can use the backup to recover as a fallback if there are problems with port and certificate changes, and then return to the original configuration.
Common questions
Q: Can you directly change the program to listen on port 80?A: Yes, but usually there is no need to do so. Directly listening on port 80 may conflict with services on the same machine, and certificate and redirect management are not as clear as placing them all in the proxy layer.
Q: What's the problem with accessing the domain 502?A: It is mostly because the target of proxy forwarding is unreachable: confirm that the container or process is running on port 8001, the firewall allows loopback forwarding on the local machine, and the target port in the port mapping and proxy configuration is consistent.
Q: Do the old addresses with ports and external links need to be handled?A: Yes. Redirect these addresses with 301 to the standard domain name, so that the weight of the existing external links and visitors are all attributed to the main address.