New Virtualmin-nginx update returns [invalid condition ""$scheme""] error

SYSTEM INFORMATION

OS type and version Ubuntu 20.04.4
Webmin version 1.994
Virtualmin version 7.1-1
Related packages N/A

After the latest virtualmin-nginx update (webmin-virtualmin-nginx), the following error keeps popping up whenever I try to make certain nginx-related changes (like auto-redirect http to https via Server Configuration → Website Options):

configuration is invalid : nginx: [emerg] invalid condition ""$scheme"" in /etc/nginx/sites-enabled/example.com.conf:59 nginx: configuration file /etc/nginx/nginx.conf test failed

FWIW, the above error references the following section of the configuration file:

        if ("$scheme" = http) {
                rewrite ^/(?!.well-known)(.*) "https://example.com/$1" break;
        }

I ended up removing the above snippet from the sites-available (not sites-enabled) conf file and nginx is working fine again but re-enabling “Redirect all requests to SSL site” creates the above snippet again and the error comes back. Previously created virtual servers didn’t have the above snippet when enabling “Redirect all requests to SSL site” so I’m not sure what’s going on.

Ok so I found a manual fix for this by removing the quotes from $scheme like this:

        if ($scheme = http) {
                rewrite ^/(?!.well-known)(.*) "https://example.com/$1" break;
        }

@Ilia @Joe Can you please check this out? Not sure why $scheme is wrapped around quotes after the latest update.

By quickly looking at the code I do not see that we add quotes to $scheme. I presume it must have been added outside of Virtualmin.

The above snippet is generated whenever I try to enable Server Configuration → Website Options->Redirect all requests to SSL site. I am not sure if it’s something I added or if it’s related to the new update but I’ll try setting up Virtualmin with default config on a fresh server later this week and see if I can replicate this.

Same problem here. The latest webmin-virtualmin-nginx will be auto added around quotes to parameters on Nginx conf. Please check and fix it, thanks so much!

I am using Adding Nginx config directives in Server Templates > Plugin options to add aditional nginx config to every Virtual server when it’s created. My aditional nginx config not have any double quotes, but when a Virtual Server was created, my aditional nginx config in /etc/nginx/sites-available/domain-xxx.conf has auto added double quotes around all parameters.

Eg:

My original aditional nginx config:

if ($server_port !~ 443){
rewrite ^(/.*)$ https://$host$1 permanent;
}

When a Virtual Server is created, it will auto added double quotes like this:

if ("$server_port" !~ 443){
rewrite "^(/.*)$" "https://$host$1" permanent;
}

So, Nginx alert an error, and this make SSL Renew not working too, please fix this, sir! Thanks so much! @staff

What is Virtualmin Nginx plugin version do you have installed (can be checked on System Settings ⇾ Features and Plugins page or by running webmin --versions)?

I cannot yet reproduce this issue in neither described cases.

2.26 sir, The latest version, I have received a notice to update it to 2.26 few days ago.

Alright, thanks for the update. I see an issue with Nginx plugin version 2.26.

1 Like

Yeah! Please fix this, thanks so much, sir <3

This has been fixed here: Fix not to wrap Nginx variables · virtualmin/virtualmin-nginx@fca7001 · GitHub

@Ilia Thanks for the fix Ilia :fist:

Hi sir, how can I update this into my server? Thanks!

Debian derivatives:

wget  -O /usr/share/webmin/virtualmin-nginx/virtualmin-nginx-lib.pl https://raw.githubusercontent.com/virtualmin/virtualmin-nginx/fca7001e09eb83ca3ddf3d96864ff3e2f5d3ff63/virtualmin-nginx-lib.pl

RHEL derivatives:

wget  -O /usr/libexec/webmin/virtualmin-nginx/virtualmin-nginx-lib.pl https://raw.githubusercontent.com/virtualmin/virtualmin-nginx/fca7001e09eb83ca3ddf3d96864ff3e2f5d3ff63/virtualmin-nginx-lib.pl
3 Likes

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.