Skip to content

修改配置报错runtime error: invalid memory address or nil pointer dereference #357

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
Sanbobo1 opened this issue Apr 26, 2024 · 29 comments · Fixed by #376
Closed

修改配置报错runtime error: invalid memory address or nil pointer dereference #357

Sanbobo1 opened this issue Apr 26, 2024 · 29 comments · Fixed by #376
Labels
bug Something isn't working question Further information is requested

Comments

@Sanbobo1
Copy link

新增了【环境】配置中的一台节点机器,可以看到该机器的监控信息,目录下的配置文件,但是点击修改后报错runtime error: invalid memory address or nil pointer dereference
image

image
image

@Sanbobo1 Sanbobo1 added the bug Something isn't working label Apr 26, 2024
@Sanbobo1
Copy link
Author

但是修改本机的配置是可以正常操作的

@0xJacky
Copy link
Owner

0xJacky commented Apr 26, 2024

可否提供一下被控的机器上nginx ui的日志

@Sanbobo1
Copy link
Author

bash <(curl -L -s https://mirror.ghproxy.com/https://raw.githubusercontent.com/0xJacky/nginx-ui/master/install.sh) install -r https://mirror.ghproxy.com/ 我是以这种方式部署的,请问nginx ui的日志在哪个路径下

@0xJacky
Copy link
Owner

0xJacky commented Apr 26, 2024

使用 journalctl -u nginx-ui -f 获取实时日志

@Sanbobo1
Copy link
Author

image
点击链接进来后第一个报错:
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: 2024-04-26 17:20:14 ERROR router/middleware.go:24 runtime error: invalid memory address or nil pointer dereference
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: goroutine 226 [running]:
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: github.com/0xJacky/Nginx-UI/router.InitRouter.recovery.func2.1()
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: /home/runner/work/nginx-ui/nginx-ui/router/middleware.go:23 +0x65
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: panic({0x3402e20?, 0x6f510d0?})
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: /opt/hostedtoolcache/go/1.22.1/x64/src/runtime/panic.go:770 +0x132
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: gorm.io/gorm.(*DB).getInstance(0x31d4a60?)
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: /home/runner/go/pkg/mod/gorm.io/gorm@v1.25.7/gorm.go:399 +0x12
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: gorm.io/gorm.(*DB).Model(...)
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: /home/runner/go/pkg/mod/gorm.io/gorm@v1.25.7/chainable_api.go:19
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: github.com/0xJacky/Nginx-UI/api/cosy.(*Ctx[...]).result(0x47c1740)
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: /home/runner/work/nginx-ui/nginx-ui/api/cosy/list.go:66 +0x39a
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: github.com/0xJacky/Nginx-UI/api/cosy.(*Ctx[...]).PagingListData(0x47c1740)
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: /home/runner/work/nginx-ui/nginx-ui/api/cosy/list.go:107 +0x36
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: github.com/0xJacky/Nginx-UI/api/cosy.(*Ctx[...]).PagingList(0x0)
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: /home/runner/work/nginx-ui/nginx-ui/api/cosy/list.go:156 +0x1c
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: github.com/0xJacky/Nginx-UI/api/notification.GetList(0xc00222f300)
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: /home/runner/work/nginx-ui/nginx-ui/api/notification/notification.go:29 +0xa5
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: github.com/gin-goni
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: [GIN] 2024/04/26 - 17:20:14 | 500 | 231.264µs | 192.168.5.167 | GET "/api/notifications"
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: 2024-04-26 17:20:14 ERROR router/middleware.go:24 runtime error: invalid memory address or nil pointer dereference
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: goroutine 232 [running]:
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: github.com/0xJacky/Nginx-UI/router.InitRouter.recovery.func2.1()
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: /home/runner/work/nginx-ui/nginx-ui/router/middleware.go:23 +0x65
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: panic({0x3402e20?, 0x6f510d0?})
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: /opt/hostedtoolcache/go/1.22.1/x64/src/runtime/panic.go:770 +0x132
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: github.com/0xJacky/Nginx-UI/internal/environment.RetrieveEnvironmentList()
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: /home/runner/work/nginx-ui/nginx-ui/internal/environment/environment.go:11 +0x21
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: github.com/0xJacky/Nginx-UI/api/cluster.GetEnvironmentList(0xc001c41900)
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: /home/runner/work/nginx-ui/nginx-ui/api/cluster/environment.go:30 +0x1c
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: github.com/gin-gonic/gin.(*Context).Next(0xc001c41900)
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: /home/runner/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 +0x2b
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: github.com/0xJacky/Nginx-UI/router.InitRouter.proxy.func6(0xc001c41900)
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: /home/runner/work/nginx-ui/nginx-ui/router/proxy.go:18 +0x145
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: github.com/gin-gonic/gin.(*Context).Next(0xc001c41900)
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: /home/runner/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 +0x2b
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: github.com/0xJacky/Nginx-UI/router.InitRouter.authRequired.func
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: [GIN] 2024/04/26 - 17:20:14 | 500 | 99.106µs | 192.168.5.167 | GET "/api/environments"
Apr 26 17:20:14 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: [GIN] 2024/04/26 - 17:20:14 | 200 | 4.703579ms | 192.168.5.167 | GET "/api/analytic/init"

@Sanbobo1
Copy link
Author

点击修改时的报错日志:
Apr 26 17:21:18 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: 2024-04-26 17:21:18 ERROR router/middleware.go:24 runtime error: invalid memory address or nil pointer dereference
Apr 26 17:21:18 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: goroutine 215 [running]:
Apr 26 17:21:18 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: github.com/0xJacky/Nginx-UI/router.InitRouter.recovery.func2.1()
Apr 26 17:21:18 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: /home/runner/work/nginx-ui/nginx-ui/router/middleware.go:23 +0x65
Apr 26 17:21:18 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: panic({0x3402e20?, 0x6f510d0?})
Apr 26 17:21:18 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: /opt/hostedtoolcache/go/1.22.1/x64/src/runtime/panic.go:770 +0x132
Apr 26 17:21:18 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: github.com/0xJacky/Nginx-UI/api/config.GetConfig(0xc00205b500)
Apr 26 17:21:18 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: /home/runner/work/nginx-ui/nginx-ui/api/config/get.go:34 +0x17b
Apr 26 17:21:18 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: github.com/gin-gonic/gin.(*Context).Next(0xc00205b500)
Apr 26 17:21:18 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: /home/runner/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 +0x2b
Apr 26 17:21:18 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: github.com/0xJacky/Nginx-UI/router.InitRouter.proxy.func6(0xc00205b500)
Apr 26 17:21:18 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: /home/runner/work/nginx-ui/nginx-ui/router/proxy.go:18 +0x145
Apr 26 17:21:18 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: github.com/gin-gonic/gin.(*Context).Next(0xc00205b500)
Apr 26 17:21:18 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: /home/runner/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 +0x2b
Apr 26 17:21:18 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: github.com/0xJacky/Nginx-UI/router.InitRouter.authRequired.func5(0xc00205b500)
Apr 26 17:21:18 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: /home/runner/work/nginx-ui/nginx-ui/router/middleware.go:48 +0xcf
Apr 26 17:21:18 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: github.com/gin-gonic/gin.(*Context).Next(0xc00205b500)
Apr 26 17:21:18 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: /home/runner/go/pkg/mod/github.com/g
Apr 26 17:21:18 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: [GIN] 2024/04/26 - 17:21:18 | 500 | 189.175µs | 192.168.5.167 | GET "/api/config/bdzsbeta.cxmuc.com.conf"
Apr 26 17:21:18 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[26999]: [GIN] 2024/04/26 - 17:21:18 | 200 | 83.637µs | 192.168.5.167 | POST "/api/nginx/test"

@0xJacky
Copy link
Owner

0xJacky commented Apr 26, 2024

ok. 有进展会通知你

@Sanbobo1
Copy link
Author

ERROR analytic/analytic.go:82 write tcp 10.10.6.193:9002->192.168.5.167:51412: write: broken pipe
ERROR analytic/nodes.go:64 write tcp 10.10.6.193:9002->192.168.5.167:51410: write: broken pipe
还有这些报错 是有需要开放的端口吗

@0xJacky
Copy link
Owner

0xJacky commented Apr 26, 2024

这个没事,websocket我没处理好

@0xJacky
Copy link
Owner

0xJacky commented Apr 26, 2024

被控的机器上看一下 /usr/local/etc/nginx-ui 目录下有没有 database.db 然后试下在被控机重启 systemctl restart nginx-ui

这个问题看起来是像是数据库相关的,我这边复现不了

@0xJacky 0xJacky added the question Further information is requested label Apr 26, 2024
@Sanbobo1
Copy link
Author

/usr/local/etc/nginx-ui 目录下没有 database.db

@0xJacky
Copy link
Owner

0xJacky commented Apr 28, 2024

/usr/local/etc/nginx-ui 目录下没有 database.db

那你先访问被控机器的 ip:port/install 安装并初始化数据库,这个问题应该就解决了,或者直接copy主sever上的 db 过去也可以,重启 nginx-ui

@Sanbobo1
Copy link
Author

cp主sever上的 db 过去,重启被控的nginx-ui,还是有报错。
Apr 28 10:56:47 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[28880]: 2024-04-28 10:56:47 ERROR router/middleware.go:24 runtime error: invalid memory address or nil pointer dereference
Apr 28 10:56:47 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[28880]: goroutine 93 [running]:
Apr 28 10:56:47 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[28880]: github.com/0xJacky/Nginx-UI/router.InitRouter.recovery.func2.1()
Apr 28 10:56:47 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[28880]: /home/runner/work/nginx-ui/nginx-ui/router/middleware.go:23 +0x65
Apr 28 10:56:47 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[28880]: panic({0x3402e20?, 0x6f510d0?})
Apr 28 10:56:47 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[28880]: /opt/hostedtoolcache/go/1.22.1/x64/src/runtime/panic.go:770 +0x132
Apr 28 10:56:47 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[28880]: github.com/0xJacky/Nginx-UI/api/config.GetConfig(0xc001c0c700)
Apr 28 10:56:47 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[28880]: /home/runner/work/nginx-ui/nginx-ui/api/config/get.go:34 +0x17b
Apr 28 10:56:47 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[28880]: github.com/gin-gonic/gin.(*Context).Next(0xc001c0c700)
Apr 28 10:56:47 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[28880]: /home/runner/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 +0x2b
Apr 28 10:56:47 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[28880]: github.com/0xJacky/Nginx-UI/router.InitRouter.proxy.func6(0xc001c0c700)
Apr 28 10:56:47 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[28880]: /home/runner/work/nginx-ui/nginx-ui/router/proxy.go:18 +0x145
Apr 28 10:56:47 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[28880]: github.com/gin-gonic/gin.(*Context).Next(0xc001c0c700)
Apr 28 10:56:47 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[28880]: /home/runner/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 +0x2b
Apr 28 10:56:47 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[28880]: github.com/0xJacky/Nginx-UI/router.InitRouter.authRequired.func5(0xc001c0c700)
Apr 28 10:56:47 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[28880]: /home/runner/work/nginx-ui/nginx-ui/router/middleware.go:48 +0xcf
Apr 28 10:56:47 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[28880]: github.com/gin-gonic/gin.(*Context).Next(0xc001c0c700)
Apr 28 10:56:47 cx-beta-upgrade-php-7-4-33-10-10-6-193 nginx-ui[28880]: /home/runner/go/pkg/mod/github.com/gi

@0xJacky
Copy link
Owner

0xJacky commented Apr 28, 2024

那试一下webui能初始化吗

@0xJacky
Copy link
Owner

0xJacky commented Apr 28, 2024

ip:port/install

@Sanbobo1
Copy link
Author

ip:port/install 用这个初始化之后,web界面登录报错了。登入后一瞬间,马上弹出authentication failed

image

@Sanbobo1
Copy link
Author

image

@0xJacky
Copy link
Owner

0xJacky commented Apr 28, 2024

清一下浏览器的缓存再试一下?
#342
看起来很像是这个问题,但是我没法复现

@Sanbobo1
Copy link
Author

目前只能被控机器只能通过ip:port/install的方式吗,我内网的机器都是linux的。如果都需要这样方式的话,每台被控机器都要配一个公网/域名去转发进行初始化,很麻烦

@0xJacky
Copy link
Owner

0xJacky commented Apr 28, 2024

理论上是不需要的,只要有 database.db 就可以,哦对了还有 app.ini 里面的 JwtSecret 要配置,这样数据库应该就能正常初始化了

@0xJacky
Copy link
Owner

0xJacky commented Apr 28, 2024

配好 app.ini 和 database.db 一起复制过去应该就可以,事实上我开发环境做迁移的时候也是这么干的😂

@Sanbobo1
Copy link
Author

嗯 配好 app.ini 和 database.db 一起复制过去 可以了。
登录的问题,换个浏览器可以了,应该是缓存问题。

@Sanbobo1
Copy link
Author

Sanbobo1 commented Apr 28, 2024

提个问题:目前我在配置管理里面看到,只能针对conf对应目录的conf文件进行修改,如果我有新增配置需求,是否只能在【新增站点】功能下进行配置。并且该功能只能进行填写相关信息进行配置,如果我有多台负载均衡的机器,则需要配置多次。这里是否有直接编写conf 反向代理配置文件,并下发到多台机器的功能呢

@0xJacky
Copy link
Owner

0xJacky commented Apr 28, 2024

对,目前还不支持新增 conf,等我把 ssl 部分改完再看看

@Sanbobo1
Copy link
Author

提个建议:有一个机器组的概念,这样我新增conf或修改后(同名覆盖二次确认)就可以下发到多台负载均衡的机器,不用逐一配置。

@0xJacky
Copy link
Owner

0xJacky commented Apr 28, 2024

开新的 issue 吧

@Sanbobo1
Copy link
Author

好的

@jearton
Copy link

jearton commented May 2, 2024

我也遇到了,被控机器没有初始化用户导致的。但是被控机器,本来就不需要用户名+密码登录,而是通过key+api控制的,那初始化用户是否多余呢? @0xJacky

@0xJacky 0xJacky reopened this May 3, 2024
@0xJacky
Copy link
Owner

0xJacky commented May 3, 2024

我也遇到了,被控机器没有初始化用户导致的。但是被控机器,本来就不需要用户名+密码登录,而是通过key+api控制的,那初始化用户是否多余呢? @0xJacky

这个确实要改进

@0xJacky 0xJacky linked a pull request May 5, 2024 that will close this issue
9 tasks
0xJacky added a commit that referenced this issue May 6, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working question Further information is requested
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants