Repository navigation
Console: redirect plain HTTP to HTTPS on a TLS port - #2
Merged
Merged
Conversation
Typing 192.168.1.50:8787 into a phone tries http:// first, and with LAN access on (or -tls-self-signed) Go answered with "Client sent an HTTP request to an HTTPS server". The listener now looks at the first byte of each connection: TLS handshakes go to the console, anything else gets a temporary redirect to the same address over https://.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reported from testing v1.4.0 on a phone: entering
192.168.x.x:8787withouthttps://showed Go's "Client sent an HTTP request to an HTTPS server" error, because phone browsers try plain HTTP first.What changes
-tls-self-signed/-tls-cert), its listener peeks at the first byte of each connection. A TLS handshake (0x16) goes to the console as before. Anything else goes to a small server that answers with a 302 redirect tohttps://<same host><same path>.Testing
TestSelfSignedTLSnow checks that plain HTTP on the TLS port returns a 302 with the rightLocation(path and query kept), and that HTTPS still serves the dashboard.