Skip to content

Redirect http to https #3105

Apr 17, 2025 · 1 comments · 1 reply

You must be logged in to vote

Let me see IIUC.
You have a listener that expects HTTPS, that is, it is ready to call mg_tls_init() on connect and will initiate/process a TLS handshake after that, and handle incoming data over TCP as TLS records.
You want that listener to "guess" that what is coming is not a TLS handshake or a TLS record but an HTTP message.
I don't see such a thing is possible. mg_url_is_ssl() does not work on the request, it works on the URL you pass as an argument, it can't whatsoever know if the browser request is HTTP or HTTPS, because there is no such thing as "an HTTPS request", HTTPS is just HTTP over TLS, so you first start a TLS encrypted pipe, then send HTTP over that pipe. You would need to …

Replies: 1 comment 1 reply

You must be logged in to vote
1 reply
@steteb

Answer selected by scaprile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants