Skip to content

Instantly share code, notes, and snippets.

@fgbreel
Created December 15, 2015 23:06
Show Gist options
  • Save fgbreel/f323f3e38cb6eb0750c9 to your computer and use it in GitHub Desktop.
Save fgbreel/f323f3e38cb6eb0750c9 to your computer and use it in GitHub Desktop.
Ansible template for Apache2.4 with Load Balancing
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin [email protected]
DocumentRoot {{ document_root }}
LogLevel error
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLProxyEngine on
SSLCertificateFile {{ ssl_certificate_path }}
SSLCertificateKeyFile {{ ssl_certificate_key_path }}
SSLCACertificateFile {{ ssl_ca_certificate_path }}
ProxyPreserveHost On
ProxyAddHeaders On
RequestHeader set X-Forwarded-Proto 'https'
RequestHeader set Https 'on'
BalancerPersist On
<Proxy balancer://default>
{% for host in groups['app'] %}
BalancerMember http://{{ host }}:8080
{% endfor %}
</Proxy>
<Location />
ProxyPass balancer://default/
ProxyPassReverse balancer://default
</Location>
</VirtualHost>
</IfModule>
@fgbreel
Copy link
Author

fgbreel commented Dec 15, 2015

must be used with:

- apache2_module: name={{ item }} state=present
  with_items:
    - headers
    - ssl
    - proxy
    - proxy_http
    - proxy_connect
    - proxy_balancer
    - lbmethod_byrequests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment