Website Redirects feature never creates permanent redirects when using Nginx

Hi,

We are using Nginx and need to redirect requests from one domain to another. Both domains are virtual servers configured properly in Virtualmin.

On the source domain (the one I want to redirect requests from), I've set up a redirect using the Server Configuration > Website Redirects feature. I set the source URL to "/", the destination URL to https://www.example.com/$1, the redirect type to permanent (301), and have chosen to include subpaths in the redirect. Saving my changes produces no errors.

However, when I go in and edit the redirect to verify everything, the redirect type is set back to default. If I set it to permanent, save my changes, and then go back and edit the redirect again, it is back to being set at default.

Looking at the raw virtual host configuration file, this is what it shows:

rewrite ^/(?!.well-known)(.*) https://www.example.com/ break;

When, according to the Nginx documentation, permanent redirects should look like this:

rewrite ^/(?!.well-known)(.*) https://www.example.com/ permanent;

Making this change manually in the virtual server configuration file and then restarting Nginx results in the correct 301 redirect.

Upon further investigation, it appears the rewrite rule doesn't actually include subpaths as I specified in the Virtualmin redirect configuration. A permanent redirect line that causes subpaths to work properly should look like this:

rewrite ^/(?!.well-known)(.*)$ https://www.example.com/$1 permanent;

Status: 
Fixed (pending)
Virtualmin version: 
6.14
Webmin version: 
1.962

Comments

Thanks for pointing this out - we'll add support for different redirect codes in the next release of the Nginx plugin.

Hello! I see that Virtualmin 6.15 is now available, along with new versions of Webmin and Usermin as well. Has the Nginx plugin also been updated to address, for example, the items mentioned in this issue? Thanks!

Ilia's picture
Submitted by Ilia on Fri, 03/12/2021 - 11:56

Has the Nginx plugin also been updated to address, for example, the items mentioned in this issue?

Not yet, I will try releasing it tomorrow though, after fixing few bugs.

Ilia's picture
Submitted by Ilia on Sat, 03/13/2021 - 07:57

Update version of Virtualmin Nginx module has been scheduled for a release.