force_ssl for easy apache/nginx redirection to https (TEMPLATES)(SKINS)

Version 1.55

Feature
Finished

New checkbox in both: User Level -> Domain Setup -> domain.com under the "private_html setup for domain.com" table, showing: [ ] Force SSL with https redirect and at bottom of this page: User Level -> domain.com -> SSL Certificates where, if checked, the port 80 VirtualHost/server{} entries for a domain/subdomains will automatically redirect to the same host and request, but with https. ==================== DOMAIN CONFIGS New setting will be: force_ssl=yes in the: /usr/local/directadmin/data/users/username/domains/domain.com.conf if it's turned on. If it's off, it will be absent from the file (will not show force_ssl=no) ==================== JSON CMD_ADDITIONAL_DOMAINS?action=view&domain=domain.com&json=yes will now include the: "force_ssl": "yes", if turned on. If off, it will be absent from the output. ==================== SKINS /usr/local/directadmin/data/skins/enhanced/user/modify_domain.html In the "private_html setup" table, below the 2 radio tr entries for the link, add a new row: <tr><td class=list2><input type="checkbox" name="force_ssl" value="yes" |SSLDISABLED| |FORCE_SSL_CHECKED|></td><td class=list2>|LANG_FORCE_SSL_REDIRECT|</td></tr> /usr/local/directadmin/data/skins/enhanced/user/ssl.html <table class=mb15 cellpadding=3 cellspacing=1> <form name=https action="/CMD_DOMAIN" method="post"> <input type=hidden name=action value="private_html"> <input type=hidden name=domain value="|DOMAIN|"> <tr><td><input type="checkbox" name="force_ssl" value="yes" |FORCE_SSL_CHECKED|></td> <td>|LANG_FORCE_SSL_REDIRECT|</td> <td><input type=submit value='|LANG_SAVE|'></td> </tr> </form> </table> where it uses the same action=private_html form.. but really has nothing to do with the symbolic link, since both radio buttons are excluded from the form. ==================== TEMPLATES Changed: /usr/local/directadmin/data/templates/ -- virtual_host2.conf virtual_host2_sub.conf nginx_server.conf nginx_server_sub.conf added token: |FORCE_SSL_REDIRECT| which, if set in the Domain Setup for that domain, will be filled with either: SetEnvIf X-Forwarded-Proto \"https\" HTTPS=on RewriteEngine On RewriteCond %{HTTPS} !=on RewriteCond %{HTTP:X-Forwarded-Proto} !https [NC] RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] OR if ($http_x_forwarded_proto != 'https') { return 301 https://$host$request_uri; }

Interested to try DirectAdmin? Get a 30-day Free Trial!