Browse Source

force https

master
parent
commit
660b7e6095
4 changed files with 67 additions and 0 deletions
  1. +4
    -0
      handlers/main.yml
  2. +32
    -0
      tasks/main.yml
  3. +23
    -0
      templates/apache2_default-ssl_vhost.conf.j2
  4. +8
    -0
      templates/apache2_default_vhost.conf.j2

+ 4
- 0
handlers/main.yml View File

@@ -0,0 +1,4 @@
- name: apache2 reload
service:
name: apache2
state: reloaded

+ 32
- 0
tasks/main.yml View File

@@ -65,3 +65,35 @@
# get_url:
# url: http://localhost/postfixadmin/setup.php
# dest: /var/www/html/postfixadmin-setup-report.html

- name: apache2 default vhost config
template:
src: apache2_default_vhost.conf.j2
dest: /etc/apache2/sites-available/000-default.conf
notify:
- apache2 reload

- name: apache2 default-ssl vhost config
template:
src: apache2_default-ssl_vhost.conf.j2
dest: /etc/apache2/sites-available/default-ssl.conf
notify:
- apache2 reload

- name: apache2 default-ssl vhost enable
file:
src: ../sites-available/default-ssl.conf
dest: /etc/apache2/sites-enabled/default-ssl.conf
state: link
notify:
- apache2 reload

- name: apache2 ssl module enable
apache2_module:
name: ssl
state: present
notify:
- apache2 reload

- name: flush handlers
meta: flush_handlers

+ 23
- 0
templates/apache2_default-ssl_vhost.conf.j2 View File

@@ -0,0 +1,23 @@
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin webmaster@localhost

DocumentRoot /var/www/html

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

SSLEngine on

SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>

</VirtualHost>
</IfModule>

+ 8
- 0
templates/apache2_default_vhost.conf.j2 View File

@@ -0,0 +1,8 @@
<VirtualHost *:80>
ServerAdmin webmaster@localhost

Redirect / https://{{inventory_hostname}}/

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Loading…
Cancel
Save