tidb-dashboard
tidb-dashboard copied to clipboard
Empty `path-prefix` parameter doesn't work with Nginx "/" location
Bug Report
What did you do?
Use TiDB Dashboard with Nginx reverse proxy. Followed doc step-by-step. Doc url.
Start PD with:
[dashboard]
public-path-prefix = "/"
Then config Nginx with:
server {
listen 2379;
location / {
proxy_pass http://192.168.48.3:2379/dashboard/;
}
}
192.168.48.3:2379is the URL of PD service
What did you expect to see?
Access dashboard with http://{nginx_address}:2379. Dashboard should work well.
What did you see instead?

What version of TiDB Dashboard are you using (./tidb-dashboard --version)?
v6.4.x
Here is the Nginx access log:
[223.166.189.93](http://223.166.189.93/) - - [16/Dec/2022:15:47:34 +0800] "GET /dashboard/api/info/info HTTP/1.1" 404 14 "http://47.92.231.206:2379/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/[108.0.0.0](http://108.0.0.0/) Safari/537.36" "-"
[223.166.189.93](http://223.166.189.93/) - - [16/Dec/2022:15:47:34 +0800] "GET /dashboardApp.css.map HTTP/1.1" 200 188061 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/[108.0.0.0](http://108.0.0.0/) Safari/537.36" "-"
[223.166.189.93](http://223.166.189.93/) - - [16/Dec/2022:15:47:37 +0800] "GET /chunk-HC5PF7O5.js.map HTTP/1.1" 200 3303897 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/[108.0.0.0](http://108.0.0.0/) Safari/537.36" "-"
The /dashboard/api/info/info api call failed, while the /dashboardApp.css.map assert call succeed.
This bug could related to following lines:
- https://github.com/SabaPing/tidb-dashboard/blob/d02b6af853a3cac31c7a4c031347b8f6f9be9732/pkg/config/config.go#L75
- https://github.com/SabaPing/tidb-dashboard/blob/194ab10cbfa3e9934d92a5cc4d4a379811a7150d/pkg/uiserver/uiserver.go#L52
One more case:
If the following configs are used:
[dashboard]
public-path-prefix = "/"
Then config Nginx with:
server {
listen 2379;
location /dashboard/ {
proxy_pass http://192.168.48.3:2379/dashboard/;
}
}
The dashboard homepage (login) can be accessed, but after login, it always shows a blank page. Some requests are failed:'
