Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Nginx does not reload when adding a site, enabling a site, or disabling a site #222

Closed
sanvu88 opened this issue Dec 6, 2023 · 11 comments
Closed
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@sanvu88
Copy link
Contributor

sanvu88 commented Dec 6, 2023

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
@sanvu88 sanvu88 added the bug Something isn't working label Dec 6, 2023
@0xJacky
Copy link
Owner

0xJacky commented Dec 6, 2023

Can you provide the logs?

@wienfuchs
Copy link

wienfuchs commented 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
Copy link
Contributor Author

sanvu88 commented Dec 6, 2023

Can you provide the logs?

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

@0xJacky
Copy link
Owner

0xJacky commented Dec 6, 2023

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

@0xJacky
Copy link
Owner

0xJacky commented 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
Copy link
Contributor Author

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

@0xJacky
Copy link
Owner

0xJacky commented Dec 6, 2023

In this verison, I use two separate commands to restart nginx.

out = execCommand("nginx", "-s", "stop")
out += execCommand("nginx")

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.

@0xJacky
Copy link
Owner

0xJacky commented 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
Copy link
Contributor Author

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

@0xJacky 0xJacky added the documentation Improvements or additions to documentation label Dec 6, 2023
@sanvu88
Copy link
Contributor Author

sanvu88 commented 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
Copy link
Owner

0xJacky commented 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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
Status: Done
Development

No branches or pull requests

3 participants