修复ui路径404的问题

This commit is contained in:
bjd 2021-01-11 18:45:40 +08:00
parent 206cfebb9a
commit a72fc63c06
4 changed files with 12 additions and 13 deletions

View File

@ -25,7 +25,7 @@ AnyLink 服务端仅在CentOS7测试通过如需要安装在其他系统
## Installation ## Installation
> 升级 go version = 1.16 > 升级 go version = 1.15
```shell ```shell
git clone https://github.com/bjdgyc/anylink.git git clone https://github.com/bjdgyc/anylink.git
@ -101,13 +101,12 @@ iptables -t nat -A POSTROUTING -s 192.168.10.0/255.255.255.0 -o eth0 -j MASQUERA
1. 创建桥接网卡 1. 创建桥接网卡
``` ```
注意 server.toml 的ip参数需要与 bridge.sh 的配置参数一致 注意 server.toml 的ip参数需要与 bridge-init.sh 的配置参数一致
``` ```
2. 修改 bridge.sh 内的参数 2. 修改 bridge-init.sh 内的参数
``` ```
# file: ./bridge.sh
eth="eth0" eth="eth0"
eth_ip="192.168.1.4" eth_ip="192.168.1.4"
eth_netmask="255.255.255.0" eth_netmask="255.255.255.0"
@ -115,10 +114,10 @@ eth_broadcast="192.168.1.255"
eth_gateway="192.168.1.1" eth_gateway="192.168.1.1"
``` ```
3. 执行 bridge.sh 文件 3. 执行 bridge-init.sh 文件
``` ```
sh bridge.sh sh bridge-init.sh
``` ```
## Soft ## Soft

View File

@ -56,7 +56,7 @@ func authMiddleware(next http.Handler) http.Handler {
route := mux.CurrentRoute(r) route := mux.CurrentRoute(r)
name := route.GetName() name := route.GetName()
// fmt.Println("bb", r.URL.Path, name) // fmt.Println("bb", r.URL.Path, name)
if name == "login" || name == "static" { if utils.InArrStr([]string{"login", "index", "static"}, name) {
// 不进行鉴权 // 不进行鉴权
next.ServeHTTP(w, r) next.ServeHTTP(w, r)
return return

View File

@ -15,13 +15,12 @@ func StartAdmin() {
r := mux.NewRouter() r := mux.NewRouter()
r.Use(authMiddleware) r.Use(authMiddleware)
r.Handle("/", http.RedirectHandler("/ui/", http.StatusFound)). r.Handle("/", http.RedirectHandler("/ui/", http.StatusFound)).Name("index")
Name("static") r.PathPrefix("/ui/").Handler(
r.PathPrefix("/ui/").Handler(http.FileServer( http.StripPrefix("/ui/", http.FileServer(http.Dir(base.Cfg.UiPath))),
http.Dir(base.Cfg.UiPath), ).Name("static")
)).Name("static")
r.HandleFunc("/base/login", Login).Name("login") r.HandleFunc("/base/login", Login).Name("login")
r.HandleFunc("/set/home", SetHome) r.HandleFunc("/set/home", SetHome)
r.HandleFunc("/set/system", SetSystem) r.HandleFunc("/set/system", SetSystem)
r.HandleFunc("/set/soft", SetSoft) r.HandleFunc("/set/soft", SetSoft)

View File

@ -83,6 +83,7 @@ func initServerCfg() {
Cfg.DbFile = getAbsPath(base, Cfg.DbFile) Cfg.DbFile = getAbsPath(base, Cfg.DbFile)
Cfg.CertFile = getAbsPath(base, Cfg.CertFile) Cfg.CertFile = getAbsPath(base, Cfg.CertFile)
Cfg.CertKey = getAbsPath(base, Cfg.CertKey) Cfg.CertKey = getAbsPath(base, Cfg.CertKey)
Cfg.UiPath = getAbsPath(base, Cfg.UiPath)
Cfg.DownFilesPath = getAbsPath(base, Cfg.DownFilesPath) Cfg.DownFilesPath = getAbsPath(base, Cfg.DownFilesPath)
if len(Cfg.JwtSecret) < 20 { if len(Cfg.JwtSecret) < 20 {