nginx配置如下,127.0.0.1:8068为后台服务(根据后台部署实际IP和端口进行修改)
server
{
listen 80;
server_name 域名/外网IP;
index index.html;
root /data/dist; #dist上传的路径
# 避免访问出现 404 错误
location / {
try_files $uri $uri/ @router;
index index.html;
}
location @router {
rewrite ^.*$ /index.html last;
}
# 接口
location /api {
proxy_pass http://127.0.0.1:8068;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
# 授权接口
location /auth {
proxy_pass http://127.0.0.1:8068;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
# aws授权接口
location /k8s-wrapper {
proxy_pass http://127.0.0.1:8068;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
# WebSocket 服务
location /webSocket {
proxy_pass http://127.0.0.1:8068;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
# 头像
location /avatar {
proxy_pass http://127.0.0.1:8068;
}
# 文件
location /file {
proxy_pass http://127.0.0.1:8068;
}
}
启动nginx服务
访问
在浏览器输入 http://127.0.0.1
, 默认账号为admin
,密码123456
,如能正常访问表示启动成功。
管理中心控制台一般为企业内部运维人员使用,可不配置外网访问权限。