Skip to content

Commit

Permalink
Nginx 反向代理适配;
Browse files Browse the repository at this point in the history
  • Loading branch information
shaohq committed Dec 25, 2020
1 parent 3a821f0 commit 2a6d783
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 33 deletions.
2 changes: 1 addition & 1 deletion install/v3-upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ meta:
-e KUBOARD_AGENT_SERVER_UDP_PORT="10081" \
-e KUBOARD_AGENT_SERVER_TCP_PORT="10081" \
-v /root/kuboard-data:/data \
eipwork/kuboard:v3.0.0-alpha.4
eipwork/kuboard:v3.0.0-beta.5
```

::: danger 请注意
Expand Down
90 changes: 58 additions & 32 deletions install/v3/proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,45 +16,71 @@ meta:

在为 Kuboard 配置反向代理时,需要注意:
* WebContextRoot
* Kuboard 需要使用根路径进行访问,即 https://yourkuboard.yourcompany.com/,而不能是 https://yourcompany.com/kuboard/ 这样的二级路径;
* Kuboard 需要使用根路径进行访问,即 https://kuboard.mycompany.com/,而不能是 https://mycompany.com/kuboard/ 这样的二级路径;
* 启用 WebSocket
* Kuboard 中终端和日志的功能需要用到 WebSocket,需要在您的反向代理中配置 WebSocket,才能正常使用 Kuboard 的终端和日志功能;
* PassHeader
* Kuboard v3 的 Portforward <Badge>v3.0.0</Badge> 功能需要用到 SPDY 协议,需要您的反向代理能够支持此协议,并将 Upgrade,Connection,Authorization 这几个 Header 传递给 Kuboard。
<!-- * PassHeader
* Kuboard v3 的 Portforward <Badge>v3.0.0</Badge> 功能需要用到 SPDY 协议,需要您的反向代理能够支持此协议,并将 Upgrade,Connection,Authorization 这几个 Header 传递给 Kuboard。 -->

## 配置样例

### Nginx 配置

当前情况下 Kuboard v3.0.0 如果运行在反向代理之后,会出现日志、终端界面不可用的情况,此问题还在解决。

<!-- 如果您使用 nginx 作为反向代理,配置文件样例如下所示:
``` nginx {7-10,17-19}
server {
listen 80;
server_name kuboard.yourdomain.com; # 替换成你的域名
location / {
proxy_pass http://192.168.2.39:80; # 替换成你的宿主机地址
proxy_http_version 1.1;
proxy_pass_header Authorization;
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 https; # 如果您在反向代理上启用了 HTTPS
gzip on;
如果您使用 nginx 作为反向代理,配置文件样例如下所示:
> Kuboard 版本不低于 v3.0.0-beta.5
``` nginx {5-8,14,15,19,22,23,31,32,34,35,36}
http {
# 您需要的其他配置
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
location /k8s {
proxy_pass http://192.168.2.39:80; # 替换成你的宿主机地址
proxy_http_version 1.1;
proxy_pass_header Authorization;
proxy_pass_header Upgrade;
proxy_pass_header Connection;
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 https; # 如果您在反向代理上启用了 HTTPS
server {
listen 80;
server_name kuboard.mycompany.com; # 替换成你的域名,应该与 KUBOARD_ENDPOINT 中的域名部分保持一致
location / {
proxy_pass http://192.168.32.205:10080/; # 替换成你的 Kuboard IP 地址和端口,应该是 IP 地址,而不是 KUBOARD_ENDPOINT 参数的值
gzip on;
}
location /k8s-ws/ {
proxy_pass http://192.168.32.205:10080/k8s-ws/; # 替换成你的 Kuboard IP 地址和端口
proxy_http_version 1.1;
proxy_pass_header Authorization;
proxy_set_header Upgrade "websocket";
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 https; # 如果您在反向代理上启用了 HTTPS
}
location /k8s-proxy/ {
proxy_pass http://192.168.32.205:10080/k8s-proxy/; # 替换成你的 Kuboard IP 地址和端口
proxy_http_version 1.1;
proxy_pass_header Authorization;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $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 https; # 如果您在反向代理上启用了 HTTPS
gzip on;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
gzip on;
}
``` -->
```

0 comments on commit 2a6d783

Please sign in to comment.