0

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 got a script (backend and two Android apps) that works perfectly on http, but the apps have a payment gateway that works only with https. The author of the code created a doc that teaches you how to install the backend on the server in an automated way, just install 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, 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 webmaster@localhost
    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 webmaster@localhost
    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, 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?

0

Your Apache approach is correct. And, your app configuration is also correct (i.e. https://example.com).

It could be an intermediate certificate issue because of which your app is not trusting the cert and unable to open HTTPS connection to apache.

Or it could be an application error side on app side.

Regardless, would it be possible for you to get more error information and post it here. That way we can guide you further.

Thx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.