Hosting an HTML via golang webserver

I have a small golang app that creates an HTML file and hosts it:

func startHttpServer() {
	port := ":8089"
	dirname := "html"
	fs := http.FileServer(http.Dir(dirname))
	mux := http.NewServeMux()
	mux.Handle("/", fs)
	log.Fatal(http.ListenAndServeTLS(port, "/var/snap/platform/current/syncloud.crt", "/var/snap/platform/current/syncloud.key", mux))
}

… and it almost works. Connecting to https://<local-ip>:8089/file.html works. The page is displayed as expected. (As you can see I use Syncloud’s certificate, so I have to confirm that I trust the page because the certificate is only valid for <name>.syncloud.it, but then it works.)
However, connecting from outside via my actual URL does not work: https://<name>.syncloud.it:8089/file.html shows this error message in Firefox:

Secure Connection Failed
An error occurred during a connection to [name].syncloud.it:8089. PR_END_OF_FILE_ERROR
Error code: PR_END_OF_FILE_ERROR

And this is what Chrome displays:

This site can’t be reached
The connection was reset.
Try:

ERR_CONNECTION_RESET

curl reports an SSL error:

curl -v https://[name].syncloud.it:8089/file.html
* Host [name].syncloud.it:8089 was resolved.
* IPv6: (none)
* IPv4: [public-ip]
*   Trying [public-ip]:8089...
* Connected to [name].syncloud.it ([public-ip]) port 8089
* ALPN: curl offers h2,http/1.1
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
*  CAfile: /etc/ssl/certs/ca-certificates.crt
*  CApath: none
* OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to [name].syncloud.it:8089 
* Closing connection
curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to [name].syncloud.it:8089

Any idea what’s wrong?
Cheers!

Hi,

Is port 8089 visible outside your bome network?
Do you see different curl response on 8090 (non existent for sure) for example?

Yes, I enabled that port. When disabled:

curl -v https://[name].syncloud.it:8089/file.html
* Host [name].syncloud.it:8089 was resolved.
* IPv6: (none)
* IPv4: [public-ip]
*   Trying [public-ip]:8089...
* Connected to [name].syncloud.it ([public-ip]) port 8089
* ALPN: curl offers h2,http/1.1
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
*  CAfile: /etc/ssl/certs/ca-certificates.crt
*  CApath: none
* Recv failure: Connection reset by peer
* OpenSSL SSL_connect: Connection reset by peer in connection to [name].syncloud.it:8089 
* Closing connection
curl: (35) Recv failure: Connection reset by peer

Ok it is hard to say without trying it myself.
Do you have the same version of ip (6 or 4) on both ends (router and machine your are running curl on)?
You could send the url to the support email so I can check.

Oh Jesus, I figured it out!
Turns out port 8089 is not viable for IPv6 and IPv4 for some reason. My router only opened port 8089 for IPv6 and silently opened a different port for IPv4. Hence, I couldn’t connect via IPv4 on that port …
I don’t remember why I chose 8089, probably randomly. Apparently, it is reserved or something.

Thanks a lot – one more time – Boris, for the fast support! :rocket: Your question about IPv4/IPv6 brought me on the right track, this has been bugging me for WEEKS.

1 Like