virtualmin-nginx-fpm icon indicating copy to clipboard operation
virtualmin-nginx-fpm copied to clipboard

SSL Redirect option is not working on Nginx

Open jonyoi opened this issue 6 years ago • 7 comments

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 domain.com.conf

server { server_name domain.com www.domain.com; listen ipaddress:80; rewrite ^/(.*) https://domain.com/$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.

Thanks

jonyoi avatar Apr 11 '18 16:04 jonyoi

If you're using this module then you should select domain and then navigate to Services -> Manage Nginx PHP-FPM website. There you'll see Enable SSL checkbox. After saving domain configuration you'll get following inside Nginx config:

server {
    server_name $d->{'dom'} www.$d->{'dom'};
    listen $d->{'ip'};
    rewrite ^ https://\$server_name\$request_uri? permanent;
}

So, yes, it is 301 redirect. However no Let's Encrypt integration done yet. So you'll have to deal with adding SSL certs manually.

Real-Gecko avatar Apr 11 '18 16:04 Real-Gecko

Thanks for your response, However I was unable to locate option "Manage Nginx PHP-FPM website" under services. Please check the snapshot.

http://prntscr.com/j3wh80

I did go under "Configure Nginx Website" and enabled SSL there under "SSL settings", but that didnt do the trick.

jonyoi avatar Apr 11 '18 16:04 jonyoi

This means you're using stock Nginx module, that now supports PHP-FPM. I'm not using stock module, so I cannot give you any advice.

Real-Gecko avatar Apr 11 '18 16:04 Real-Gecko

can you please tell me which Nginx module I should be using switching to, in order to make it work?

jonyoi avatar Apr 11 '18 16:04 jonyoi

You can switch to this module, but as I sad earlier it does not support seamless integration with Let's Encrypt.

Real-Gecko avatar Apr 11 '18 16:04 Real-Gecko

alright, but if I am using the redirect code in domain.com.conf as I mentioned above, its essentially doing the same thing, right? I just wanna make sure I am not missing out on any cool jazz. Below is the code again for reference.

server { server_name domain.com www.domain.com; listen ipaddress:80; rewrite ^/(.*) https://domain.com/$1 permanent; }

jonyoi avatar Apr 11 '18 16:04 jonyoi

I use rewrite ^ https://$server_name$request_uri? permanent;, dunno if it makes any difference though.

Real-Gecko avatar Apr 11 '18 17:04 Real-Gecko