{% if ACTIVATE_HTTPS %}
<VirtualHost *:80>
   ServerName {{ LMS_HOST }}
   Redirect / https://{{ LMS_HOST }}/
</VirtualHost>
<VirtualHost *:80>
   ServerName preview.{{ LMS_HOST }}
   Redirect / https://preview.{{ LMS_HOST }}/
</VirtualHost>
<VirtualHost *:80>
   ServerName {{ CMS_HOST }}
   Redirect / https://{{ CMS_HOST }}/
</VirtualHost>

<VirtualHost *:443>
    ServerName {{ LMS_HOST }}
    ServerAlias preview.{{ LMS_HOST }} {{ CMS_HOST }}
    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/{{ LMS_HOST }}/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/{{ LMS_HOST }}/privkey.pem

    ProxyPreserveHost On
    ProxyRequests On
    ProxyPass / http://localhost:{{ NGINX_HTTP_PORT }}/
    ProxyPassReverse / http://localhost:{{ NGINX_HTTP_PORT }}/
</VirtualHost>
{% else %}
<VirtualHost *:80>
    ServerName {{ LMS_HOST }}
    ServerAlias preview.{{ LMS_HOST }} {{ CMS_HOST }}

    ProxyPreserveHost On
    ProxyRequests On
    ProxyPass / http://localhost:{{ NGINX_HTTP_PORT }}/
    ProxyPassReverse / http://localhost:{{ NGINX_HTTP_PORT }}/
</VirtualHost>
{% endif %}

{{ patch("proxy-apache") }}
