<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerAdmin __LETSENCRYPT_EMAIL__
    ServerName __SITE_DOMAIN__
    DocumentRoot __SITE_ROOT__

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

    SetEnv VIDX_HLS_BASE_ORIGIN "http://127.0.0.1:8888"
    SetEnv VIDX_STATS_BASE_ORIGIN "http://127.0.0.1:8888"

    <Directory __SITE_ROOT__>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    Include /etc/letsencrypt/options-ssl-apache.conf
    SSLCertificateFile /etc/letsencrypt/live/__SITE_DOMAIN__/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/__SITE_DOMAIN__/privkey.pem

    ProxyPreserveHost On

    ProxyPass "/streamedian/ws/" "ws://127.0.0.1:8080/ws/"
    ProxyPassReverse "/streamedian/ws/" "ws://127.0.0.1:8080/ws/"

    ProxyPass "/hls/" "http://127.0.0.1:8888/"
    ProxyPassReverse "/hls/" "http://127.0.0.1:8888/"

    ProxyPass "/webrtc/" "http://127.0.0.1:8889/"
    ProxyPassReverse "/webrtc/" "http://127.0.0.1:8889/"

    ProxyPass "/live-stats/feed.json" "http://127.0.0.1:9997/v3/paths/list"
    ProxyPassReverse "/live-stats/feed.json" "http://127.0.0.1:9997/v3/paths/list"

    Header always set Access-Control-Allow-Methods "GET, OPTIONS"
    Header always set Access-Control-Allow-Headers "Range, Content-Type"
</VirtualHost>
</IfModule>
