<VirtualHost *:80>
    ServerName widget.bambuyo.com
    Redirect permanent / https://widget.bambuyo.com/
</VirtualHost>

<VirtualHost *:443>

    ServerName widget.bambuyo.com

    DocumentRoot /var/www/bambuyo-widget
    DirectoryIndex index.php

    <Directory /var/www/bambuyo-widget>
       Options Indexes FollowSymLinks MultiViews
       AllowOverride All
       Order allow,deny
       allow from all
    </Directory>

    # NO CACHE for app.js - critical for widget updates
    <FilesMatch "app\.js$">
        Header set Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0"
        Header set Pragma "no-cache"
        Header set Expires "0"
    </FilesMatch>

    <FilesMatch \.php$>
      # For Apache version 2.4.10 and above, use SetHandler to run PHP as a fastCGI process server
      SetHandler "proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhost"
    </FilesMatch>

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

    ErrorLog ${APACHE_LOG_DIR}/bambuyo-widget.error.log
    CustomLog ${APACHE_LOG_DIR}/bambuyo-widget.access.log combined

</VirtualHost>