AddApiClaim 消息到 RabbitMQ(含 claim、IP、Port)。ProxyAutomation 服務消費消息,生成 Nginx 配置片段,SCP 部署並 nginx -s reload。include 通配符動態加載上游與路由配置。http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
}
# conf.d/api.example.com.conf
include /etc/nginx/conf.d/api.example.com.conf.d/upstream.*.conf;
server {
listen 80;
server_name api.example.com;
include /etc/nginx/conf.d/api.example.com.conf.d/location.*.conf;
location / { root /usr/share/nginx/api.example.com; }
}
upstream stock {
server 10.0.0.23:8001;
server 10.0.0.23:8002; # 輪詢負載均衡
}
location /stock/ {
proxy_pass https://stock;
}
SSH.NET 庫執行遠程 SCP 與命令。upstream.xxx.conf + location.xxx.conf → reload。事件驅動的 Nginx 配置自動化,將反向代理從靜態配置提升為動態基礎設施組件,完美契合微服務與雲原生架構的服務發現需求。