Forcing http to https redirect

Remitur

Verified User
Joined
May 11, 2018
Messages
69
Location
Sežana (Slovenia)
Hello.

I just set up an email-only DA server; configured LE in order to issue the SSL certificate for webmail.example.com, and checked about forcing the redirect from http to https

Certificate issue works fine, I can access to https://webmail.example.com without any issue, but if I try to access to http://webmail.example.com I stay on the non-secure environment, instead of being redirect to https...

(note: accessing to DA administrative interface, i.e. http://myserver.ext:2222 , the redirect to https works fine...)

Anything I'm missing about https redirect forcing?
 
Hello,

You might try the following:

Code:
cd /usr/local/directadmin/custombuild
./build update
./build set redirect_host $(hostname -f)
./build set redirect_host_https yes
./build set use_hostname_for_alias yes 
./build rewrite_confs

as root.
 
Hello, sorry for reviving an old thread..
i'm having the same issue, specifically with the 'webmail' subdomain on all of the domains on the server..
i'd like to enforce https everywhere, but the above code did not do it for me..

i was wondering whether it would be best to edit the file:
/usr/local/directadmin/data/templates/custom/virtual_host2.conf.CUSTOM.4.post
So that it reads:
Code:
</VirtualHost>
<VirtualHost |IP|:|PORT_80| |MULTI_IP|>
    ServerName webmail.|DOMAIN|
    ServerAdmin |ADMIN|
    DocumentRoot /var/www/html/roundcube
    CustomLog /var/log/httpd/domains/|DOMAIN|.bytes bytes
    CustomLog /var/log/httpd/domains/|DOMAIN|.log combined
    ErrorLog /var/log/httpd/domains/|DOMAIN|.error.log
    <IfModule !mod_ruid2.c>
        SuexecUserGroup webapps webapps
    </IfModule>
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
    </IfModule>
    <IfModule !mod_rewrite.c>
        Redirect / https://webmail.|DOMAIN|
    </IfModule>
 
Last edited:
i tried my suggestion above.. seems to work..

Just to be clear, all i added was the following code to the file
/usr/local/directadmin/data/templates/custom/virtual_host2.conf.CUSTOM.4.post
Code:
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
    </IfModule>
    <IfModule !mod_rewrite.c>
        Redirect / https://webmail.|DOMAIN|
    </IfModule>

then ran
build rewrite_confs
 
Back
Top