# Redirect HTTP to HTTPS
<VirtualHost *:80>
    ServerName whatsapp.wifimtaani.top
    Redirect permanent / https://whatsapp.wifimtaani.top/
RewriteEngine on
RewriteCond %{SERVER_NAME} =whatsapp.wifimtaani.top
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

# Secure HTTPS vhost
<VirtualHost *:443>
    ServerName whatsapp.wifimtaani.top

    ProxyPreserveHost On

    # Normal HTTP API traffic
    ProxyPass / http://127.0.0.1:3000/
    ProxyPassReverse / http://127.0.0.1:3000/

    # WebSocket Support
    RewriteEngine On
    RewriteCond %{HTTP:Upgrade} =websocket [NC]
    RewriteRule /(.*) ws://127.0.0.1:3000/$1 [P,L]

    # SSL Config
    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/whatsapp.wifimtaani.top/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/whatsapp.wifimtaani.top/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

