The core function of Nginx reverse proxy is to forward external requests to the internal AnQiCMS application, while handling static files, optimizing connections, and providing an additional layer of security protection.It blocks the actual running port of AnQiCMS, only exposing the standard web service port to the outside, making the entire architecture more robust and secure.
Basic environment preparation before deploying AnQiCMS
Before starting to configure Nginx reverse proxy, we need to ensure that the server already has the Nginx service. Usually, in most Linux distributions, this can be done through a package manager (such asaptoryumInstall Nginx easily.In addition, the AnQiCMS application itself also needs to be deployed and run.8001Port. This means that the executable file of AnQiCMS is already running on the server before the Nginx configuration, and can be accessed locally127.0.0.1:8001Access.
The deployment process of AnQiCMS usually includes downloading the Linux installation package from the official website, unzipping it to a specified directory, such as/www/wwwroot/anqicms.com. Then, by executingstart.shThe script to start the AnQiCMS service, which will startanqicmsMain program, making it listen on the configured port.This port is the target for Nginx to perform reverse proxy.publicIn the folder, Nginx needs to be configured to directly serve these static resources to improve access efficiency.
Nginx Reverse Proxy Configuration Example
Here is a detailed Nginxserverblock configuration example, used towww.yourdomain.comAll requests under the domain are reverse proxied to the locally running AnQiCMS application and static files are processed with priority:
`nginx server {
# Nginx监听的端口,通常为HTTP的80端口
listen 80;
# 您的网站域名,可以同时包含PC端和移动端域名
server_name www.yourdomain.com yourdomain.com; # 示例:www.anqicms.com m.anqicms.com
# 网站的静态文件根目录。这应该指向您的AnQiCMS安装目录下的 public 文件夹。
# Nginx会先尝试在这里查找请求的静态文件。
root /www/wwwroot/anqicms.com/public;
# 定义一个命名location,专门用于将请求代理到AnQiCMS应用。
# 当 try_files 无法找到匹配的静态文件时,请求会被转发到这里。
location @AnqiCMS {
# 将请求转发到AnQiCMS应用监听的地址和端口。
# 127.0.0.1 是本地回环地址,8001 是AnQiCMS默认监听的端口。
proxy_pass http://127.0.0.1:8001;