Apache configured without https

This commit is contained in:
2016-09-19 02:00:29 +03:00
parent 2fe380d8b1
commit 4d126502bd
7 changed files with 145 additions and 39 deletions
+68 -14
View File
@@ -1,12 +1,11 @@
---
- hosts: apache2
become: yes
vars:
tmpl:
- {file: "static", value: 'Use DocRootVHost "static.rudolf" "/home/www/static"' }
- {file: "syncthing", value: 'Use ProxySSLVHost "syncthing.rudolf" "/" "http://localhost:{{ syncthing_port }}/" "syncthing.rudolf"' }
- {file: "jenkins", value: 'Use ProxySSLVHost "jenkins.rudolf" "/" "http://localhost:{{ jenkins_port }}/" "jenkins.rudolf"' }
- { file: "101-syncthing", value: 'Use ProxyHost "syncthing.rudolf" "/" "http://localhost:{{ syncthing_port }}/" "syncthing.rudolf"' }
- { file: "102-jenkins", value: 'Use ProxyHost "jenkins.rudolf" "/" "http://localhost:{{ jenkins_port }}/" "jenkins.rudolf"' }
# - {file: "static", value: 'Use DocRootVHost "static.rudolf" "/home/www/static"' }
# - {file: "torrent", value: 'Use ProxySSLVHost "torrent.rudolf" "/transmission" "http://localhost:9091/transmission" "torrent.rudolf"' }
# - {file: "", value: '# TODO Header edit Location ^http://jenkins.rudolf.com.ua https://jenkins.rudolf.com.ua' }
# - {file: "webmin", value: 'Use ProxySSLVHost "webmin.rudolf" "/" "http://localhost:10000/" "webmin.rudolf"' }
@@ -16,6 +15,9 @@
- name: install apache2
apt: name=apache2 update_cache=yes state=latest
- name: install libapache2-mod-auth-openidc
apt: name=libapache2-mod-auth-openidc state=latest
- name: apache2 listen on port {{ http_port }} and {{ https_port }}
lineinfile:
dest: /etc/apache2/ports.conf
@@ -28,22 +30,43 @@
notify:
- restart apache2
- name: macro lib
copy:
src: apache2/macro.conf
dest: /etc/apache2/conf-enabled/macro.conf
- name: populate configs
template:
src: "{{ item }}"
dest: /etc/apache2/conf-enabled/my-{{ item | basename }}
with_fileglob:
- apache2/conf/*.conf
register: apache2_configs
notify:
- restart apache2
- name: find existing files
find:
paths: /etc/apache2/conf-enabled
patterns: "my-*.conf"
register: existing_configs
- name: remove stale configs
file: path="{{ item }}" state=absent
with_items:
existing_configs.files|default([])|map(attribute='path')|list|
difference(
apache2_configs.results|default([])|map(attribute='path')|list
)|
list|default([])
notify:
- restart apache2
- name: enabling modules
apache2_module:
name: "{{ item }}"
state: present
name: "{{ item.name }}"
state: "{{ item.state }}"
with_items:
- proxy_http
- rewrite
- macro
# - ssl TODO
- { name: proxy_http , state: present }
- { name: rewrite , state: present }
- { name: macro , state: present }
- { name: auth_openidc , state: present }
- { name: ssl , state: absent }
notify:
- restart apache2
@@ -53,6 +76,7 @@
dest: /etc/apache2/sites-enabled/{{ item | basename }}
with_fileglob:
- apache2/templates/*.conf
register: apache2_templates
notify:
- restart apache2
@@ -61,6 +85,36 @@
content: "{{ item.value }}"
dest: "/etc/apache2/sites-enabled/{{ item.file }}.conf"
with_items: tmpl
register: apache2_proxies
when: tmpl
notify:
- restart apache2
- name: find existing files
find:
paths: /etc/apache2/sites-enabled
patterns: "*.conf"
register: existing_files
- name: debug
debug:
var: "{{ item }}"
with_items:
- apache2_proxies
- apache2_templates
- existing_files
- name: remove stale files
file: path="{{ item }}" state=absent
with_items:
existing_files.files|default([])|map(attribute='path')|list|
difference(
apache2_proxies.results|default([])|rejectattr("dest", "none")|map(attribute='dest')|list
)|
difference(
apache2_templates.results|default([])|map(attribute='path')|list
)|
default([])
notify:
- restart apache2
+11 -14
View File
@@ -34,18 +34,7 @@
</Macro>
<Macro ProxyVHost $domain $proxyPrefix $proxyUrl $sslDomain>
<VirtualHost *:80>
ServerAdmin rudolfss13@gmail.com
ServerName $domain.com.ua
ProxyPass $proxyPrefix $proxyUrl retry=0
ProxyPassReverse $proxyPrefix $proxyUrl
</VirtualHost>
</Macro>
<Macro ProxySSLVHost $domain $proxyPrefix $proxyUrl $sslDomain>
<Macro ProxyHost $domain $proxyPrefix $proxyUrl $sslDomain>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin rudolfss13@gmail.com
@@ -58,15 +47,23 @@
</VirtualHost>
</IfModule>
</Macro>
<VirtualHost *:80>
ServerAdmin rudolfss13@gmail.com
ServerName $domain.com.ua
ProxyPass $proxyPrefix $proxyUrl retry=0
ProxyPassReverse $proxyPrefix $proxyUrl
</VirtualHost>
</Macro>
<Macro MacroSSL $domain>
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/$domain.com.ua/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/$domain.com.ua/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/$domain.com.ua/chain.pem
SSLCertificateChainFile /etc/letsencrypt/live/$domain.com.ua/chain.pem
</Macro>
+1
View File
@@ -0,0 +1 @@
ServerName rudolf.com.ua
@@ -28,4 +28,5 @@
## Virtual hosts
Use DocRootVHost "rudolf" "/home/www/root"
# Use DocRootVHost "rudolf" "/home/www/root"
Use ProxyHost "rudolf" "/" "http://localhost:{{ gogs_port }}/" "rudolf"
@@ -10,6 +10,7 @@
SSLCertificateKeyFile /etc/letsencrypt/live/smarthome.rudolf.com.ua/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/smarthome.rudolf.com.ua/chain.pem
Use GoogleAuth https://smarthome.rudolf.com.ua/oauth2callback /
<Location />
+1 -10
View File
@@ -45,7 +45,7 @@
- "/var/jenkins:/var/jenkins_home"
ports:
- "0.0.0.0:{{ jenkins_port }}:8080"
- "0.0.0.0:{{ jenkins_ci }}:50000"
- "0.0.0.0:{{ jenkins_cli }}:50000"
state: reloaded
- name: install jenkins plugins
@@ -56,15 +56,6 @@
become_user: rudolf
# - name: Install jenkins plugins
# get_url:
# url: http://updates.jenkins-ci.org/latest/{{ item.name }}.hpi
# dest: /var/jenkins/plugins
# with_items:
# - { name: "git"}
# notify: restart jenkins docker
handlers:
- name: restart jenkins docker
docker_container:
+61
View File
@@ -0,0 +1,61 @@
---
- hosts: apache2
become: yes
vars:
domains:
- rudolf.com.ua
- jenkins.rudolf.com.ua
- syncthing.rudolf.com.ua
- smarthome.rudolf.com.ua
# - static.rudolf.com.ua
# - torrent.rudolf.com.ua
# - dev.rudolf.com.ua
# - ejudge.rudolf.com.ua
# - webmin.rudolf.com.ua
# - bitsync.rudolf.com.ua
# - wa.rudolf.com.ua
tasks:
- name: install letsencrypt
apt: name=letsencrypt state=latest
- name: apache stopped
service:
name: apache2
state: stopped
enabled: yes
- name: install certificates
shell: "letsencrypt certonly --standalone -n -d {{ item }} --email aleksander.rudenko.g@gmail.com --agree-tos"
with_items: domains
- name: apache sarted
service:
name: apache2
state: started
enabled: yes
# rudolf.com.ua
# jenkins.rudolf.com.ua
# torrent.rudolf.com.ua
# syncthing.rudolf.com.ua
# dev.rudolf.com.ua
# ejudge.rudolf.com.ua
# webmin.rudolf.com.ua
# smarthome.rudolf.com.ua
# bitsync.rudolf.com.ua
# wa.rudolf.com.ua
# static.rudolf.com.ua
# ./letsencrypt-auto renew --standalone
# ./letsencrypt-auto certonly --standalone -d rudolf.com.ua