How to enable access to example.com:8080 (Docker) with https (Apache) for using Android apps

I will try to explain my situation but I apologize right now because I started studying the subject a little while ago and maybe I don’t know how to give all the details correctly.

I recently purchased a script (backend and two Android apps) that work perfectly with the http site path, but the apps have a payment gateway that works only with https. The author of the code created documentation that teaches how to install the backend on the server in an automated way, just install the Docker and run the backend with the link wget http://authorsite/docker-compose.yaml && docker-compose up -d.

The installation created the containers for the database and the backend files, and created a docker-compose.yaml file:

 version: '3'

 services:
   mysql:
     image: mysql
     command: --default-authentication-plugin=mysql_native_password
     volumes:
       - mysqlvol:/var/lib/mysql
     environment:
       MYSQL_ROOT_PASSWORD: defaultpassword

   redis:
     image: redis
     volumes:
       - redisvol:/data

   taxi:
     image: author/taxi
     restart: always
     depends_on:
       - "redis"
       - "mysql"
     volumes:
       - ./img:/app/public/img
       - ./config:/app/config
       - taxiassets:/app/public/assets
     links:
       - mysql
       - redis
     ports:
       - "8080:8080"

 volumes:
    redisvol:
    mysqlvol:
    taxiassets:

The backend page started working at http://example.com:8080 and I just needed to add the same url in the apps, in the config.kt file:

class Config {
    companion object {
        const val Backend = "http://example.com:8080/"
    }
}

Everything works fine, but as I mentioned, I need https for the payment gateway to work in apps, and also to get rid of http. The author does not give this information for free, so I researched and found some tutorials on reverse proxy, I already had Apache installed on my server (outside of Docker) and followed the tutorials related to Apache.

My .conf file (with Let’s Encrypt) looked like this:

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerAdmin [email protected]
    ServerName example.com
    ServerAlias www.example.com
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    
    ProxyPass / http://127.0.0.1:8080/
    ProxyPassReverse / http://127.0.0.1:8080/
    ProxyPreserveHost On
    ProxyPassReverseCookiePath / /

    <Proxy *>
        Order deny,allow
        Allow from all
        Allow from localhost
    </Proxy>

Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
</VirtualHost>
</IfModule>
<IfModule mod_ssl.c>
<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName example.com
    ServerAlias www.example.com
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    
    ProxyPass / ws://127.0.0.1:8080/

</VirtualHost>
</IfModule>

I’m still learning and I sure must be doing something wrong, the backend still works at http://example.com:8080 but it doesn’t work at https://example.com:8080, but even so the backend has now started work correctly at https://example.com. I can access the panel with https, but when trying to open apps with https://example.com, as in the example:

class Config {
    companion object {
        const val Backend = "https://example.com/"
    }
}

Or

class Config {
    companion object {
        const val Backend = "https://example.com:8080/"
    }
}

the apps started to show connection error and are not working properly.

I don’t know if this is the correct approach, the backend works with the changes mentioned, before it was http://example.com:8080 and now I can access it at https://example.com, but this new url makes apps don’t work the same way and have connection errors. If I keep the original url:

class Config {
    companion object {
        const val Backend = "http://example.com:8080/"
    }
}

Apps are back to working normally.

What am I doing wrong? Please help me with this solution, or if there is another line of thought in which I can apply https, I would be very grateful to know.

I thank you all in advance.

Source: Docker Questions