# 主机部署:nginx 反代 适用于 `docker compose` 单机部署。平台监听 `127.0.0.1:8081`(或容器映射端口),由主机 nginx 对外提供 HTTP/HTTPS。 > 域名、IP 已脱敏;实际使用时替换为你的值。 ## nginx vhost `/etc/nginx/conf.d/lokistack.xxx.io.conf`: ```nginx server { listen 80; server_name lokistack.xxx.io; access_log /var/log/nginx/lokistack.xxx.io_access.log main; error_log /var/log/nginx/lokistack.xxx.io_error.log; location / { proxy_pass http://127.0.0.1:8081; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_read_timeout 300s; proxy_send_timeout 300s; client_max_body_size 100m; } } ``` ## 前置 WAF / SLB 时(可选) WAF 会把源 IP 改写为内网地址,需要在 `nginx.conf` 的 `http {}` 中还原真实客户端 IP,否则白名单会失效: ```nginx set_real_ip_from 192.168.x.x; # WAF 回源地址 real_ip_header X-Forwarded-For; ``` ## 内网白名单(可选) 建议统一放在 `/etc/nginx/nginx.conf` 的 `http {}`,不要散落在各 vhost(vhost 内一旦出现 `allow/deny` 会切断继承): ```nginx allow 192.168.0.0/16; allow 203.0.113.10; # 办公/跳板机出口 deny all; ``` 公网站点单独在其 vhost 内写 `allow all;`。 ## 生效 ```bash nginx -t && nginx -s reload ``` ## 验证 ```bash curl -I -H "Host: lokistack.xxx.io" http://127.0.0.1/ curl -s -X POST http://lokistack.xxx.io/api/v1/auth/login \ -H 'Content-Type: application/json' \ -d '{"username":"admin","password":"<你的密码>"}' ```