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

unexpected fastcgi_read_timeont parameter appears on line 63 or 66 of the host nginx configuration #58

Open
sbruimen opened this issue Jun 23, 2023 · 3 comments

Comments

@sbruimen
Copy link

Hello!

We use virtualmin api to create domains with custom template and installation script configured.
We use our custom post-installation script to install our web service (similar to installing WordPress product for example)

The problem is: after running the post-installation script from template and modifying the nginx configuration, on line 63 earlier, and line 66 today, an additional line "fastgi_read_timeout 60" unexpectedly appears o_O

After we noticed this bug, we counted the lines and left empty and commented lines 63-66 in our nginx config template and removed from nginx confiuration the original fastgi_read_timeout parameter to avoid parameter duplication. So it allows the system to work, but does not solve the bug.

The installation script executes after creating the domain and reads the nginx configuration file and replaces the typical PHP location section in it, adds configuration sections (about 150 lines) adapted for the correct operation of our web service.
The configuration is correct and the web services on it work successfully, it is being validated by the nginx successfully.

We have a suspicion that some parsing mechanisms of either the virtualmin kernel or the nginx plugin do not work correctly. Please tell us in which direction we can to dig deeper.

Environment:
OS Debian Linux 11
Webmin 2.0.21
Virtualmin 7.7 (LEMP bundle)
Nginx website 2.30
Nginx ssl website 1.19
nginx hosts configurations are stored in different "sites-enabled" files.

@jcameron
Copy link
Collaborator

So is the issue that your template contains fastgi_read_timeout already and Virtualmin is adding it again unnecessarily?

@sbruimen
Copy link
Author

no, the problem is different.

The algorithm:

  1. calling via API a request to create a domain "D" (virtual host) with a certain template parameter "T".
    https://www.virtualmin.com/documentation/developer/cli/create_domain/

At this point, a valid nginx configuration file is created, which already includes the fastgi_read_timeout parameter.

  1. Autostart within the "T" template of my custom perl web application installation script "S".
    https://www.virtualmin.com/documentation/developer/scripts/

In script "S":
-open the nginx host "D" configuration file
-delete the entry existing of the fastcgi_read_timeout parameter in it. (If i dont do it, the duplication error appears)
-replace the typical location section with my custom one, at the same time, I specifically leave this insert in the region of 63-66 lines:

location ~ "\.php(/|$)" {
fastcgi_pass mysocket-php:9000;
#that strings are for bug
#63
#64
#65
#66
         include fastcgi_params;
         fastcgi_index index.php;
         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
         fastcgi_param QUERY_STRING $query_string;
}

-save this file.

  1. Next, the installation script (2) and the virtual host creation command (1) are completed

After that, in fact, on line 66 of the nginx host configuration, a line suddenly appears with the fastgi_read_timeout parameter.
If i remove the commented lines 63-66, then this bug will replace the line at position 66, for example fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; and the app won't work.


Maybe opening the nginx configuration file from a install script and replacing some of the lines in it is not correct, should I use some special functions? But no information found how to do it in correct way.

@jcameron
Copy link
Collaborator

Ah, I think Virtualmin is getting confused by the modification of the Nginx config by an external process in the middle of domain creation.

Why not instead do the customization at the end of the creation process, via a post-creation script? See https://www.virtualmin.com/documentation/developer/prepost/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants