Redirect http to https on port 8080

My website is running on port 8080.
https://domain:8080/ can be accessed normally
but when i visiting http://domain:8080/,the server respond to “Client sent an HTTP request to an HTTPS server.”
I hope http8080 request will goes automaticlly to https8080

Caddyfile
domain:8080 {
	root * /root/caddy
	file_server
}

curl http://domain:8080 -v

  • Rebuilt URL to: http://domain:8080/

  • Trying ip…

  • TCP_NODELAY set

  • Connected to domain (ip) port 8080(#0)
    GET / HTTP/1.1
    Host: domain:8080
    User-Agent: curl/7.61.1
    Accept: /

  • HTTP 1.0, assume close after body
    < HTTP/1.0 400 Bad Request
    <
    Client sent an HTTP request to an HTTPS server.


You cannot run HTTP and HTTPS on the same port.

This topic was automatically closed after 30 days. New replies are no longer allowed.