HTTPS Redirect not working on Virtualmin Nginx

I am using LEMP stack with Virtual which I installed using “–bundle LEMP” while installing virtualmin on a debian9 OS.

When I below settings, The https redirect is not working on any of the domains.

System Settings --> Virtualmin Configurations --> SSL Settings --> Redirect all http to https by default --> yes

However I am able to do the redirect by adding below code in

server {
listen ipaddress:80;
rewrite ^/(.*)$1 permanent;

But I wonder why the inbuilt feature that ships with virtualmin is not working?

Please note I am using Lets’ Encrypt SSL.

on other note I wonder what type of Redirect Virtualmin does if that feature is to work? Is it also 301 redirect?

Any help on this would be immensely helpful.


I’m seeing the same behavior on Ubuntu with Nginx

I personally don’t think that setting works if you’re using NGINX.

My favourite for redirection is this block

if ($scheme = http) {
return 301 https://$host$request_uri;

but I don’t want to do it in config files, because I do it in mass for WordPress and basically every other site. Would prefer a UI or more consistent method.