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;
Comments
Submitted by JEMEDIACORP on Sun, 12/13/2020 - 22:32 Pro Licensee Comment #1
Submitted by JamieCameron on Fri, 12/18/2020 - 14:24 Comment #2
Thanks for pointing this out - we'll add support for different redirect codes in the next release of the Nginx plugin.
Submitted by JEMEDIACORP on Fri, 03/12/2021 - 11:01 Pro Licensee Comment #3
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!
Not yet, I will try releasing it tomorrow though, after fixing few bugs.
Update version of Virtualmin Nginx module has been scheduled for a release.