Since Webmin update, 502 Bad Gateway errors: Init file not created for recent virtual servers (Nginx PHP fcgi)

Since this has turned to probably be a recent Webmin bug, I'm moving the posted data from the forums to this issue. This has been tested on two different servers (running Ubuntu and Debian), with the same results.

When creating Nginx virtual servers with Virtualmin, until recently it worked well (last time here on 2016-08-07), for example automatically adding an init file such as /etc/init.d/php-fcgi-example-com. This can also be seen at Webmin > System > Bootup and Shutdown.

However, after adding today (2016-08-12) two new virtual servers or domains, in both cases Virtualmin/Webmin didn't create the init file at /etc/init.d/. Therefore, after initially running well for a while, then -when rebooting the Ubuntu server- while the old Nginx virtual servers are still working OK thanks to their init files, the new ones on the same server are not restarted because of the lack of those init files, and just give a 502 Bad Gateway error.

This first server got a recent Webmin update from 1.801 to 1.810. Webmin > System > Software Packages says the installed version of the Virtualmin module for Nginx Webserver is: webmin-virtualmin-nginx 1.8.

After additional testing on a different server (Debian on Linode), this appears to probably be a recent bug, appeared a few days ago in Webmin 1.810 (about 2016-08-09).

The three tests used installations of three Webmin versions on the server, an old one, the recent one, and the current one. The following has happened when creating Nginx virtual servers (in the three cases with the same version of the Virtualmin module, webmin-virtualmin-nginx 1.8) :

  • Webmin 1.760 -> The init file for the new Nginx virtual servers (/etc/init.d/php-fcgi-example-com) is automatically created. => OK
  • Webmin 1.801 -> The init file for the new Nginx virtual servers is automatically created as well. => OK
  • Webmin 1.810 -> The init file for the new Nginx virtual servers is not created. => Probably a very recent bug (about 2016-08-09).

The new virtual servers work well at first. This bug is only noticed after rebooting the server, when Nginx is restarted for the old virtual servers but not for the new ones, and the users get the 502 Bad Gateway errors for the new virtual servers.

If you have an idea for Virtualmin setting the init files when creating virtual servers (Nginx PHP fcgi), like it did before Webmin 1.810, I can help testing possible solutions on a local dev server. Thank you very much.

Status: 
Closed (fixed)

Comments

Of course, a workaround is to create by hand the missing init file, to keep the websites working until this bug is fixed. It's what I've done, and verified that everything works well with this temporary workaround.

An existing init file, created by a previous bug-free Webmin version, can be copied and customized by sudo or the root user for the new virtual servers, by searching and replacing the domain, user, and number of the socket folder.

For example, for a new virtual server "dev.example.com", this number can be seen in Webmin > Servers > Nginx Webserver > Edit Configuration Files > /etc/nginx/sites-available/dev.example.com.

If no old init file is available for copy and search/replace, the following is an example of a "/etc/init.d/php-fcgi-dev-example-com" init file (with domain "dev.example.com", user "dev", socket file "/var/php-nginx/111111111111111.sock/socket"):

#!/bin/sh
### BEGIN INIT INFO
# Provides: php-fcgi-dev-example-com
# Required-Start: $network $syslog
# Required-Stop: $network
# Default-Start: 2 3 5
# Default-Stop:
# Description: Start Nginx PHP fcgi server for dev.example.com
### END INIT INFO
 
case "$1" in
'start')
    su dev -c PHPRC\=\/srv\/www\/dev\/etc\/php5\ PHP_FCGI_CHILDREN\=4\ \/usr\/bin\/php\-loop\.pl\ \/usr\/bin\/php5\-cgi\ \-b\ \/var\/php\-nginx\/111111111111111\.sock\/socket\ \>\>\/srv\/www\/dev\/logs\/php\.log\ 2\>\&1\ \<\/dev\/null\ \&\ echo\ \$\!\ \>\/var\/php\-nginx\/111111111111111\.php\.pid
    RETVAL=$?
    ;;
'stop')
    su dev -c kill\ \`cat\ \/var\/php\-nginx\/111111111111111\.php\.pid\` ; sleep 1
    RETVAL=$?
    ;;
'restart')
    $0 stop ; $0 start
    RETVAL=$?
    ;;
*)
    echo "Usage: $0 { start | stop }"
    RETVAL=1
    ;;
esac
exit $RETVAL

(Updated using blockcode tag to prevent broken lines in code; see also the post below about /srv/www, /home, /var/www...).

To start the Nginx PHP fcgi virtual server for the new domain, now and on boot, with the recovered init file:

Webmin > System > Bootup and Shutdown > [X] php-fcgi-dev-example-com > Start Now and On Boot

About the temporary workaround, another change probably needed for the init file is \/srv\/www (that is, the FHS standard folder /srv/www for websites), which in most cases can be \/home (the Virtualmin default /home), or \/var\/www (the frequently used /var/www), etc.

Please, is there anything I can try to help fix this? As I said, I have a local dev server ready to test possible solutions.

As explained, Nginx virtual servers created after the last Webmin update (1.810) work well at first, but stop working after rebooting the server, because of lack of init file for the virtual server. Therefore, users will start noticing this only after a next server reboot.

And then, how users will repair their virtual servers? Is there a way to generate the init file for an already live virtual server, apart from laboriously by hand for each domain like in the temporary workaround? I would like to try any possible way. Thank you.

Sorry for the delay, we'll get back with you shortly.

What's the output of these two commands:

rpm -qa | grep webmin
rpm -qa | grep wbm

They give no output. I think I have only deb packages installed, not rpm. Using instead dpkg commands:

dpkg-query -l 'webmin'

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                       Version            Architecture       Description
+++-==========================-==================-==================-=========================================================
ii  webmin                     1.810              all                web-based administration interface for Unix systems

dpkg -l | grep 'webmin'

ii  webmin                                      1.810                                             all          web-based administration interface for Unix systems
ii  webmin-virtual-server                       5.04.gpl                                          all          Webmin module for 'Virtualmin Virtual Servers (GPL)'
ii  webmin-virtualmin-nginx                     1.8                                               all          Webmin module for 'Nginx Webserver'
ii  webmin-virtualmin-nginx-ssl                 1.4                                               all          Webmin module for 'Nginx SSL Webserver'

These packages are results for 'webmin'. For 'wbm' there are no results.

There are similar results using: Webmin > System > Software Packages > Search For Package

To reproduce this, on a Nginx test server, just create a new virtual server with Virtualmin and the latest Webmin 1.810. And verify if the init file /etc/init.d/php-fcgi-example-com is created or not for the new domain. It was not with two different servers and this version of Webmin, as explained.

I have same issue.

My package are below.

CentOS 6

webmin 1.810-1

wbm-virtual-server 5.04.gpl-1

wbm-virtualmin-nginx 1.8-1

wbm-virtualmin-nginx-ssl 1.4-1
Freddy63's picture
Submitted by Freddy63 on Mon, 08/22/2016 - 10:01

Is this going to be fixed soon? The temporary workaround doesn't work either. It says,

php-fcgi-domain-com No such a file or directory

Of course I replace domain with my domain name. I can edit file from putty but Virtualmin says it doesn't exist.

Please fix this soon.

Thanks!

The PHP-FCGI init scripts aren't being created, e.g., /etc/init.d/php-fcgi-example-com

After a reboot, it will result in 502 Bad Gateway. The PHP-FastCGI Server is not being started for the domain. I really hope this gets fixed soon. I just posted about it before I saw this thread. I can confirm the bug.

I can confirm the same issue on CentOS Linux release 7.2.1511 (Core) with nginx as reported by JG. Have also posted in above bug link, please post when a fix is released.

Sorry for the delay - looking into this now

Same issue here - Centos 6.8, Webmin 1.8.10 manually creating solved it

you can also destroy your existing file if you change the settings - so do an backup first

Hi @JamieCameron, do you know roughly when this might be fixed? Thank you for your help.

I expect to have a new Nginx plugin for Virtualmin out by the weekend

Hello Jamie,

I know you must be very busy, but this is a pretty critical bug that was introduced since the last webmin update.

Adding new virtual servers requires manually creating the PHP-FCGI scripts. I'm pretty sure everyone that is using Nginx with Virtualmin is having this issue. Could you please take a look at it and fix this asap?

Jamie, thank you very much for the fix. So, those Nginx virtual servers created with the next Webmin version will be OK, like those created with versions previous to the current one (Webmin 1.810).

However, when users will restart their servers and will begin to see the 502 Bad Gateway errors instead of their sites (because new Nginx virtual servers are working well before the first server restart only), how to repair those Nginx virtual servers that are being created with the current Webmin version?:

  • With some possible repair option in Virtualmin to recreate the init files? (This would be great).
  • Or creating the files by hand like in the workaround?
  • Or creating again the virtual servers with the next version?

Until the fix, another possibility is to use for now the previous Webmin version 1.801, which works great, instead of the current 1.810. For Debian, Ubuntu, etc.:

apt-get install webmin=1.801

This seems to work also for downgrades, and restarting just in case.

Thank you again.

The quick fix to repair existing domains (after Webmin 1.820 is out) will be to change the number of PHP child processes. This can be done from the command line, by running something like :

virtualmin modify-web --domain example.com --php-children 5

The new Webmin 1.820 is available now. I've tested it creating a new Nginx virtual server and restarting. It works well now, the init file is being created, and this bug seems fixed. Thank you!

I'm using Debian 8 and tried apt-get update && apt-get upgrade and I don't see 1.820 yet.

Kindnation, to have the new Webmin 1.820 available now, you can add the Webmin repository, following the section "Using the Webmin APT repository" (in the page Installing on Debian).

After that, you can do:

apt-get update

and

apt-cache policy webmin

to verify that the latest Webmin 1.820 has been added as available to install.

We haven't released it to the Virtualmin repos yet - I like to let it bake for a while for regular Webmin users first.