Set up Let's encrypt on apache , http -> https redirect

Job ID: 32655119

Budget: $10 – $30 USD

I am having some issue setting up let's encrypt on apache, basically I figured that the http to https redirect doesn't work properly.
I need you to take a look at the setting with me and identify what the root cause it.
This is my Let's encrypt 000-default-le-ssl.conf

<VirtualHost *:443>
ServerName api.mydomain.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine On
RewriteCond %{HTTP:Connection} Upgrade [NC]
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteRule "^(/?.*)$" ws://localhost:8000/graphql [P,L]
ProxyPass / http://localhost:8000/
#RewriteCond %{SERVER_NAME} = api.mydomain.com
#RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

SSLCertificateFile /etc/letsencrypt/live/mydomain.com/fullchain.pem
ServerAlias api.mydomain.com
SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

<VirtualHost *:443>
ServerName api.uat.mydomain.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine On
RewriteCond %{HTTP:Connection} Upgrade [NC]
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteRule "^(/?.*)$" ws://localhost:9000/graphql [P,L]
ProxyPass / http://localhost:9000/
# Some rewrite rules in this file were disabled on your HTTPS site,
# because they have the potential to create redirection loops.

# RewriteCond %{SERVER_NAME} =mydomain.com
# RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R^Z^Z^Z^Z
SSLCertificateFile /etc/letsencrypt/live/uat.mydomain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/uat.mydomain.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
This is my 000-default.conf
<VirtualHost *:80>
ServerName api.uat.mydomain.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine On
RewriteCond %{HTTP:Connection} Upgrade [NC]
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteRule "^(/?.*)$" ws://localhost:9000/graphql [P,L]
ProxyPass / http://localhost:9000/
RewriteCond %{SERVER_NAME} =api.uat.mydomain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/home/ubuntu/appletree-uat/apple-tree-frontend/dist/apple-tree-frontend"
ServerName uat.mydomain.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/home/ubuntu/appletree-uat/apple-tree-frontend/dist/apple-tree-frontend">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
FallbackResource /index.html
</Directory>
RewriteEngine on
RewriteCond %{HTTPS} !on
RewriteCond %{SERVER_NAME} =uat.mydomain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
Related categories: Linux Apache SSL