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:
- Nginx website option ‘Redirect all requests to SSL sites fails’. Virtualmin keeps showing ‘No’ after saving with ‘Yes’.
- The nginx site config appears in /etc/nginx/nginx.conf, not as a separate file in a sites_available directory, as before. Is this temporary?
- An edit was required to allow ‘Website Redirects’ not to show a bug. See BUG: Unescaped left brace in regex is illegal here in regex; marked by <-- HERE in m/^(http|https)://%{ <-- HERE HTTP_HOST}(/.*)$/ at /usr/share/webmin/virtual-server/list_redirects.cgi line 20 - #5 by johnhe