etherai / selfhosted-gateway

Self-hosted Docker native tunneling to localhost. Expose local docker containers to the public Internet via a simple docker compose interface.
https://fractalnetworks.co
GNU Affero General Public License v3.0
1.32k stars 66 forks source link

Add static port support and insecure backend #31

Closed Dotsch2005 closed 9 months ago

Dotsch2005 commented 9 months ago

Previously, when the gateway server was restarted, a random port was selected. This meant that the port always had to be adjusted on the client, which led to problems with multiple instances.

The container is now started with a random port to determine the port. The container is then deleted and started with the fixed port.

In addition, the InSecure option has been added, as the connection in Caddy does not work with self-signed certificates.

Dotsch2005 commented 9 months ago

Resolves #17

orcaBear commented 9 months ago

Hi, I just pulled and updated to this version. I first installed and setup some services a few days ago -- so might not have the best understanding.

After updating, I could no longer connect to a local nginx webserver at the TLD through the gateway. Only a blank page would load if trying to access via the gateway. I was seeing errors as:

logger=http.log.error msg=tls: first record does not look like a TLS handshake request ...
err_trace=reverseproxy.statusError (reverseproxy.go:1267)

To fix this, I just removed the tls from /etc/Caddyfile in the client link container:

mydomain.com {
    handle /.well-known/fractalnetworks/health {
            respond "OK" 200
        }

    reverse_proxy nginx:80 {
         transport http {
            # tls
            read_buffer 8192
         }
       }
}

Reloading with caddy reload --config /etc/Caddyfile then fixed the error I was seeing.

Is this a configuration error on my end, or is this part of the change to the insecure backend?

Dotsch2005 commented 9 months ago

Thank you for your feedback.

I have tested it with 3 of my clients and I did not notice the error. Sorry about that.

You are right, the transport http may only be formed if the environment variable is set at all. So the possibility would be as follows:

Parameter Insecure not set -> HTTP Backend Parameter Insecure true -> Backend with SSL Parameter Insecure false -> Backend Self-Signed SSL

I'll take care of a fix right away