saltstack-formulas/apache-formula

Support for redirect 80 to 443

wesleyarthur opened this issue ยท 4 comments

What is the best way to go about having a website with visitors hitting port 80 being redirected to 443? I'm a little confused if I need to just define *:443 for a apache.vhosts.standard pillar with ssl certs enabled. And then something else for a redirect...

You could setup 2 vhost definitions, first a redirect from port 80 to 443 and second a ssl encrypted vhost listening on 443. Something like:

apache:
  sites:
    # Force SSL: Redirect from 80 to 443
    example.com:
      port: 80
      template_file: salt://apache/vhosts/redirect.tmpl
      RedirectSource: 'permanent /'
      # Trailing slash is important
      RedirectTarget: 'https://example.com/'
    example.com_ssl:
      port: 443
      ServerName: example.com
      SSLCertificateFile: /path/to/ssl.crt
      SSLCertificateKeyFile: /path/to/ssl.key
      SSLCertificateChainFile: /path/to/ssl.ca.crt

Thanks. So what would be the commands to load this from salt. Would it be something like: sudo salt 'servers' state.apply apache.vhosts.standard ? I'm a little confused from the documentation on how the different templates get loaded because I only see an SLS file for standard, not redirect.

Update: Nevermind I found that calling apache.vhosts.standard also processes other templates. Thanks for your example above... it was very helpful.

Documented in #284

๐ŸŽ‰ This issue has been resolved in version 1.0.1 ๐ŸŽ‰

The release is available on GitHub release

Your semantic-release bot ๐Ÿ“ฆ๐Ÿš€