[GH-ISSUE #222] Nginx does not reload when adding a site, enabling a site, or disabling a site #1462

Closed
opened 2026-02-27 12:10:53 +03:00 by kerem · 11 comments
Owner

Originally created by @sanvu88 on GitHub (Dec 6, 2023).
Original GitHub issue: https://github.com/0xJacky/nginx-ui/issues/222

Describe the bug

  • Nginx does not reload when add a site, enable a site, or disable a site
  • Using Nginx Control Menu to Reload and Restart Nginx also has no effect

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:

  • Server OS: Debian 12
  • Server Arch: x64
  • Nginx UI Version: v2.0.0-beta.5-patch
  • Your Browser: Chrome
Originally created by @sanvu88 on GitHub (Dec 6, 2023). Original GitHub issue: https://github.com/0xJacky/nginx-ui/issues/222 **Describe the bug** - Nginx does not reload when add a site, enable a site, or disable a site - Using Nginx Control Menu to Reload and Restart Nginx also has no effect **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: - https://github.com/0xJacky/nginx-ui/archive/refs/tags/v2.0.0-beta.5-patch.tar.gz - https://github.com/0xJacky/nginx-ui/releases/download/v2.0.0-beta.5-patch/nginx-ui-linux-64.tar.gz **Info:** - Server OS: Debian 12 - Server Arch: x64 - Nginx UI Version: v2.0.0-beta.5-patch - Your Browser: Chrome
kerem 2026-02-27 12:10:53 +03:00
Author
Owner

@0xJacky commented on GitHub (Dec 6, 2023):

Can you provide the logs?

<!-- gh-comment-id:1842529665 --> @0xJacky commented on GitHub (Dec 6, 2023): Can you provide the logs?
Author
Owner

@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.

<!-- gh-comment-id:1842532869 --> @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.
Author
Owner

@sanvu88 commented on GitHub (Dec 6, 2023):

Can you provide the logs?

When the operation all succeeded and there was no error log from Nginx.

<!-- gh-comment-id:1842537430 --> @sanvu88 commented on GitHub (Dec 6, 2023): > Can you provide the logs? When the operation all succeeded and there was no error log from Nginx.
Author
Owner

@0xJacky commented on GitHub (Dec 6, 2023):

ok, I will try to fix it as soon as possible.

<!-- gh-comment-id:1842544707 --> @0xJacky commented on GitHub (Dec 6, 2023): ok, I will try to fix it as soon as possible.
Author
Owner

@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.

<!-- gh-comment-id:1842628268 --> @0xJacky commented on GitHub (Dec 6, 2023): I fixed in [7c6b4fe](https://github.com/0xJacky/nginx-ui/commit/7c6b4fec914534e0ea1c7734ab2198f474fcd276). 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.
Author
Owner

@sanvu88 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.

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

image

To test I did the following. First I stopped Nginx

systemctl stop nginx

then used Restart Nginx on menu

image

But, When I check Nginx's status it is actually inactive

image

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 -tupln

image

This problem will not occur when I restart Nginx directly from the server.

<!-- gh-comment-id:1842778636 --> @sanvu88 commented on GitHub (Dec 6, 2023): > I fixed in [7c6b4fe](https://github.com/0xJacky/nginx-ui/commit/7c6b4fec914534e0ea1c7734ab2198f474fcd276). 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. 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 ![image](https://github.com/0xJacky/nginx-ui/assets/12091815/827840e7-5192-4131-b8ea-147cf37dc418) To test I did the following. First I stopped Nginx `systemctl stop nginx` then used Restart Nginx on menu ![image](https://github.com/0xJacky/nginx-ui/assets/12091815/19fc2bb0-e4f1-4f0b-92b2-2b9ccdefb065) But, When I check Nginx's status it is actually inactive ![image](https://github.com/0xJacky/nginx-ui/assets/12091815/591d0e06-fd8f-41ee-9ae2-ffed4ae303ba) 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 -tupln` ![image](https://github.com/0xJacky/nginx-ui/assets/12091815/d851cf4b-d10b-42fc-ae24-76ed22ef688e) This problem will not occur when I restart Nginx directly from the server.
Author
Owner

@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 by nginx, and then using systemctl status nginx to 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.

<!-- gh-comment-id:1842859072 --> @0xJacky commented on GitHub (Dec 6, 2023): In this verison, I use two separate commands to restart nginx. https://github.com/0xJacky/nginx-ui/blob/7c6b4fec914534e0ea1c7734ab2198f474fcd276/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 by `nginx`, and then using `systemctl status nginx` to 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](https://man7.org/linux/man-pages/man8/start-stop-daemon.8.html) as default command.
Author
Owner

@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.

<!-- gh-comment-id:1842899632 --> @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.
Author
Owner

@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/nginx

then 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.

<!-- gh-comment-id:1842931651 --> @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/nginx` then 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.
Author
Owner

@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?

<!-- gh-comment-id:1842954766 --> @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?
Author
Owner

@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

  1. The nginx_log section in the configuration file has been renamed to nginx.
    NginxConfigDir and NginxPIDPath in the server section have been renamed to ConfigDir and PIDPath respectively, and both have been moved into the nginx section.
<!-- gh-comment-id:1842989793 --> @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 > 1. The nginx_log section in the configuration file has been renamed to nginx. NginxConfigDir and NginxPIDPath in the server section have been renamed to ConfigDir and PIDPath respectively, and both have been moved into the nginx section.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/nginx-ui#1462
No description provided.