Hestiacp: Request Template SSL Redirect

Created on 11 Dec 2018  路  5Comments  路  Source: hestiacp/hestiacp

Can we have a template to force HTTPS 301 redirect

The way I manually do now is

in non ssl version . after server_name Line

    # Redirect domain to www.domain
    return         301 https://www.$server_name$request_uri;

    # Redirect www to domain.com
    return         301 https://$server_name$request_uri;

in (ssl) version

    append  'ssl http2' to 'listen      IP:443'
    add_header Strict-Transport-Security "max-age=15768000" always;

    #   redirect non-www to www
    return 301 $scheme://www.domain.com$request_uri;

    #   redirect www to non-www
    if ($http_host ~* "^www.domain.tld"){ rewrite ^(.*)$ http://domain.tld$1 redirect; }

Most helpful comment

Its better to have an option in the UI to select whether HTTPs should be enforced.

All 5 comments

It can be achieved, however I believe that in order to FORCE HTTPS, separate templates are needed.

Its better to have an option in the UI to select whether HTTPs should be enforced.

Done: https://github.com/hestiacp/hestiacp/commit/108259faf27979e270cd70a297d61b8a8674bbf9

How to use: v-add-web-domain-ssl-force user domain
What it will do: It creates a file in /home/user/conf/web/ which will be included from nginx or apache2 config that forwards all traffic from http to https.

You need to have updated templates, this will be done with the next deb package. If you use custom templates, please add the custom include line you can find in the commit.

I will add a web checkbox to enable it in backend soon, for that case I reopened the issue.

Implementation in backend for admin and user is finished and tested successfully, we will push new deb packages soon: https://github.com/hestiacp/hestiacp/commit/11621dfce074cb3e9e0fd3b0c3a881c1427731da

Was this page helpful?
0 / 5 - 0 ratings

Related issues

loxK picture loxK  路  4Comments

mehargags picture mehargags  路  4Comments

ioannidesalex picture ioannidesalex  路  4Comments

kristankenney picture kristankenney  路  4Comments

xXKynarethXx picture xXKynarethXx  路  5Comments