Apache2 Proxypass, SSL and Flask

If you are running your app on a machine with a running apache and want to reach it via your domain without any port specified within the url, then you maybe should use proxypass. In my situation I wanted to rech my Flask app also if i specify the port since it was running with ssl anyway.

All you have to do is setting up your site config for apache correctly:

Listen 80
<VirtualHost *:80>
  ServerName [[YOURDOMAIN]]
  RewriteEngine On
  #redirect port 80 requests
  RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

Listen 443
<VirtualHost *:443>
  ServerName [[YOURDOMAIN]]
  SSLCertificateFile [[PATHTOYOURCERTFILE]]/cert.pem
  SSLCertificateKeyFile [[PATHTOYOURCERTKEYFILE]]/privkey.pem
  Include /etc/letsencrypt/options-ssl-apache.conf
  SSLCertificateChainFile [[PATHTOYOURCERTCHAINFILE]]/chain.pem

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

  SSLProxyEngine on
  ProxyRequests On
  ProxyPreserveHost On
  <Location />
        ProxyPassReverseCookiePath / /
        Order allow,deny
        Allow from all