# Configurazione per HTTP
<VirtualHost 65.108.222.97:80>
    ServerName ${MIOURL_API}

    RewriteEngine on
    # Redirigi tutto il traffico HTTP verso HTTPS
    RewriteCond %{SERVER_NAME} =${MIOURL_API} [OR]
    RewriteCond %{SERVER_NAME} =www.${MIOURL_API}
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

    ErrorLog /var/www/${MIODOMINIO_COMPLETO}/logs/error.log
    CustomLog /var/www/${MIODOMINIO_COMPLETO}/logs/access.log combined
</VirtualHost>

<VirtualHost 65.108.222.97:443>
  ServerName ${MIOURL_API}
  ServerAdmin surya@riso.app

  SSLEngine On
  SSLProtocol -ALL +TLSv1.2 +TLSv1.3
  SSLCompression Off
  SSLHonorCipherOrder off
  SSLCipherSuite ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:E>
  SSLVerifyDepth 10
  SSLCertificateFile /etc/letsencrypt/live/${MIODOMINIO}/cert.pem
  SSLCertificateKeyFile /etc/letsencrypt/live/${MIODOMINIO}/privkey.pem

  ProxyPreserveHost On
  SSLProxyEngine On
  SSLProxyVerify None
  SSLProxyCheckPeerCN Off
  SSLProxyCheckPeerName Off
  ProxyPass / https://localhost:${PORTA}/ retry=0 timeout=5 connectiontimeout=2
  ProxyPassReverse / https://localhost:${PORTA}/

  ProxyTimeout 5

  LogLevel warn
  ErrorLog /var/www/${MIODOMINIO_COMPLETO}/logs/error.log
  CustomLog /var/www/${MIODOMINIO_COMPLETO}/logs/access.log combined

  <Location />
    ProxyPassReverse /
    SetEnv force-proxy-request-1.0 1
    SetEnv proxy-nokeepalive 1
  </Location>
</VirtualHost>