Skip to content

Force HTTPS #15

@banderon

Description

@banderon

Howdy. Our prod site is only served over https so we wanted our local environment to follow suit. The easiest way we've found to accomplish this was running the following script prior to provisioning:

# While in `/content`
cd ../puppet/modules/chassis/templates/

# Strip off any trailing "\n" in `site.nginx.conf.erb` | remove last line, the closing `}` > save changes
awk '/^$/ {nls=nls "\n";next;} {printf "%s",nls; nls=""; print;}' site.nginx.conf.erb | sed '$d' > nginx-tmp && mv nginx-tmp site.nginx.conf.erb

# Add SSL redirect and replace closing `}`
echo '
\tif ($scheme = http) {
\t\treturn 301 https://$server_name$request_uri;
\t}
}
' >> site.nginx.conf.erb

Any thoughts as to a cleaner way of forcing HTTPS on created sites? Is this something that can potentially (optionally) be done via extension?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions