force virtual server web site to use SSL

11 posts / 0 new
Last post
#1 Fri, 12/23/2011 - 13:01
amel

force virtual server web site to use SSL

Hello,

what is the best way to force an web site to use https:// and not http:// ? I was thinking about a redirect, but users can modify the URL and just remove the httpS:// when redirected and they will be able to log-in without encryption, this is something I do not like.

Any idea ?

Thank You

Fri, 12/23/2011 - 16:49
helpmin

If you do an http redirect with apache mod_rewrite, then users wouldn't be able to remove the S. Same method can be also used to redirect a domain.com to www.domain.com (to avoid duplicate links for example).

http://httpd.apache.org/docs/2.0/misc/rewriteguide.html

Fri, 12/23/2011 - 17:29
amel

thank You for reply, I think I understand what You mean, but still not sure how to fix it. Can this be done from Virtualmin ?

Fri, 12/23/2011 - 17:36
amel

as far as I know, perhaps this config will do it ?

RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://domain.com/$1 [R,L]

Amel

Fri, 12/23/2011 - 17:36
amel

but how the manually created .htaccess will affect the Virtualmin ?

Fri, 12/23/2011 - 17:41
amel

I added the following config in the .htaccess file and it`s working just fine, the user is not able to remove the httpS:// because once he do it the redirect will take him back to https:// ...

RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://domain.com/$1 [R,L]

So the config above is tested and working just fine !

Amel

Fri, 12/23/2011 - 19:00
andreychek

Howdy,

You're quite welcome to use a .htaccess file to do that -- it's a good way to solve that problem.

I'm glad you got that working for you!

-Eric

Sat, 12/24/2011 - 04:36
amel

thanks a lot pal,

BUT one suggestion :) You could also make it possible to edit .htaccess files from Virtualmin perhaps something called "Create Cuscom .htaccess file" and open the web form where we can type the rewrite domains etc .. :)

Amel

Thu, 12/03/2015 - 02:48
marco1492
marco1492's picture

This here solved it for me.

Force the website (virtual server) to use https (SSL) instead of http. Under

Virtualmin --> Services --> Configure Website --> Edit Directives

bei RewriteEngine On

Folgendes einfügen

RewriteCond %{SERVER_PORT} 80

RewriteRule ^(.*)$ https://www.domain.com/$1 [R,L]

(Der Schrägstrich zwischen Domain und $1 musste bei mir auch noch weg, sonst gab es doppelte Schrägstriche in Domain.) Das Ganze kann auch in einer .htaccess hinterlegt werden.

Don't forget to reload/restart Apache so that the changes become effective. (button upper right corner...)

Thu, 11/16/2017 - 14:51
dzintars
dzintars's picture

Virtualmin --> Services --> Configure Website --> Edit Directives

RewriteEngine On

RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [R]

Restart Apache

Dzintars

Sun, 05/27/2018 - 03:45 (Reply to #10)
Welshman
Welshman's picture

Perfect.

Thanks dude.

VM being a GUI ( graphical user interface ) needs a click for that function otherwise what is the point ??

Chaos Reigns Within, Reflect, Repent and Reboot, Order Shall Return.

Topic locked