BUG with Virtualmin 7.3 Nginx redirect. Too much Perl code has leaked into nginx.conf causing failure

SYSTEM INFORMATION
OS type and version Rocky Linux 8.7
Webmin version 2.001
Usermin version 1.860
Virtualmin version 7.3
Theme version 20.01.1:5
Package updates All installed packages are up to date

Below is the current redirect to SSL code in nginx.conf files that now does not work. \Q and \E (to interpret literally) and the double $1 does not make sense. It looks like too much Perl code has leaked into nginx.conf, where \Q \E and /%{HTTP_HOST} does make sense.

             if ($scheme = http) {
                        rewrite "^\Q^/(?!.well-known)(.*)$\E(.*)" "https://%{HTTP_HOST}/$1$1" break;
                }

This is previous code:

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

This is a proposed fix that uses Nginx $host variable. It has been tested, including with a lets encrypt cert renewal

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

Some more notes:

For anyone who is interested, ^/(?!.well-known)(.*) is a regular expression that states if any path does not start with /.well-known then redirect to https. An exception is required to allow Lets Encrypt SSL certs to be generated and renewed automatically. ?! is advanced PCRE syntax.

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