<VirtualHost *:80>
    ServerName nomen.brchad.com

    RewriteEngine on
    RewriteCond %{SERVER_NAME} =nomen.brchad.com
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

<VirtualHost *:443>
    ServerName nomen.brchad.com

    SSLEngine on
    SSLCertificateFile    /etc/letsencrypt/live/nomen.brchad.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/nomen.brchad.com/privkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf

    ProxyPreserveHost On
    ProxyPass        / http://localhost:3002/
    ProxyPassReverse / http://localhost:3002/
    RequestHeader set X-Forwarded-Proto "https"
    RequestHeader set X-Real-IP %{REMOTE_ADDR}s

    Header always set X-Frame-Options "SAMEORIGIN"
    Header always set Content-Security-Policy "frame-ancestors 'self'"

    <LocationMatch "^/embed\.html$">
        Header always unset X-Frame-Options
        Header always set Content-Security-Policy "frame-ancestors 'self' https://caiomga.com https://www.caiomga.com https://*.brchad.com https://brchad.com https://cruzadinha.com.br https://www.cruzadinha.com.br"
    </LocationMatch>

    ErrorLog  ${APACHE_LOG_DIR}/nomen.brchad_error.log
    CustomLog ${APACHE_LOG_DIR}/nomen.brchad_access.log combined
</VirtualHost>
