安装1panel之后如何通过nginx代理访问
server {listen 80;server_name 192.168.1.5;# 1. 代理API路径(原始路径访问,无需/1panel前缀)location /api/ {proxy_pass http://192.168.1.5:42188/api/; # 直接代理API路径proxy_set_header Host $host:42188;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;}# 2. 代理1panel页面路径(/1panel前缀)location /1panel/ {proxy_pass http://192.168.1.5:42188/; # 映射到目标服务根路径proxy_set_header Host $host:42188;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;# WebSocket支持(面板终端需要)proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "upgrade";}# 3. 静态资源代理(覆盖/assets路径)location /assets/ {proxy_pass http://192.168.1.5:42188/assets/;proxy_set_header Host $host:42188;}
}
需注意静态资源、路径、API等
最重要的是官网的解决方案: