mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2026-04-25 00:36:08 +03:00
[GH-ISSUE #222] Nginx does not reload when adding a site, enabling a site, or disabling a site #5895
Labels
No labels
Q/A
bug
casdoor
dependencies
docker
documentation
duplicate
enhancement
help wanted
invalid
lego
platform:openwrt
platform:windows
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/nginx-ui#5895
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @sanvu88 on GitHub (Dec 6, 2023).
Original GitHub issue: https://github.com/0xJacky/nginx-ui/issues/222
Describe the bug
To Reproduce
I tried both the pre-built binary version and the build from source and both failed. Binary download link and Source I used:
Info:
@0xJacky commented on GitHub (Dec 6, 2023):
Can you provide the logs?
@wienfuchs commented on GitHub (Dec 6, 2023):
This issue ouccurs also with me, since latest relese of to v2.0.0-beta.5 - so it is probably located in that changes. No log access at the moment from my side, sorry. Running this through docker hub.
@sanvu88 commented on GitHub (Dec 6, 2023):
When the operation all succeeded and there was no error log from Nginx.
@0xJacky commented on GitHub (Dec 6, 2023):
ok, I will try to fix it as soon as possible.
@0xJacky commented on GitHub (Dec 6, 2023):
I fixed in 7c6b4fe. It works fine in my docker container, can you test this version, as I'm not sure it can also work well in your environment.
@sanvu88 commented on GitHub (Dec 6, 2023):
I have tested your fix and the Reload command works fine when add, disable, and enable site. However, I discovered a new problem with the Nginx restart in the Nginx Control menu
To test I did the following. First I stopped Nginx
systemctl stop nginxthen used Restart Nginx on menu
But, When I check Nginx's status it is actually inactive
Next I tried checking the listen port to see why Nginx UI reported Nginx running. Then I see that there is an Nginx process running and listening to port 80
netstat -tuplnThis problem will not occur when I restart Nginx directly from the server.
@0xJacky commented on GitHub (Dec 6, 2023):
In this verison, I use two separate commands to restart nginx.
github.com/0xJacky/nginx-ui@7c6b4fec91/internal/nginx/nginx.go (L59-L61)When you click the reload button in nginx-ui, it attempts to stop nginx whether it's running or not, that's why the error message appears if nginx is already stopped. To address this, I should check the running status of nginx before attempting to stop it.
The second problem is when starting a process without using systemtl (or services). I you use systemtl status to check the running status, it will always report inactive. To reproduce this, you can execute
nginx -s stop, followed bynginx, and then usingsystemctl status nginxto check the status.And you might notice that I use this method to restart nginx in the Line 59 to 61 in
internal/nginx/nginx.go, maybe I should use start-stop-daemon as default command.@0xJacky commented on GitHub (Dec 6, 2023):
Unfortunately, start-stop-daemon takes not effect on this issue, you have to config a nginx restart command in nginx-ui configuration file, app.ini.
@sanvu88 commented on GitHub (Dec 6, 2023):
yes, i tried use RestartCmd configuration and it worked perfectly.
i also tried start-stop-daemon command
start-stop-daemon --start --pidfile /var/run/nginx.pid --exec /usr/sbin/nginxthen the result when using start-stop-daemon is the same as using nginx -s. And if using start-stop-daemon forces users to install everything by default and will not be able to customize the path of nginx binary or pid file location.
I think using app.ini configuration will be the perfect solution.
@sanvu88 commented on GitHub (Dec 6, 2023):
If you don't mind, I have one more small question. I run nginx-ui by default, and it automatically creates the app.ini file. And I see the configuration in the app.ini file ( [server] and [nginx] )
[server]
....
NginxConfigDir =
NginxPIDPath=
[nginx]
.....
ConfigDir =
PIDPath =
Is there any difference between these two configurations?
@0xJacky commented on GitHub (Dec 6, 2023):
😂 This is a breaking change since v2.0.0-beta.3, https://github.com/0xJacky/nginx-ui/releases/tag/v2.0.0-beta.3