I can't get https working on caddy reverse proxy

thecompanydream
HOBBY

6 days ago

I have been getting the below issue:

Client sent an HTTP request to an HTTPS server.
for some reason my Caddy configuration just isn't working and I haven't working. I've copied the configuration of all the Caddy reverse proxies I've seen but none seem to work. Can anyone shine a light on this issue. I need my configuration because someone has been making weird requests to my api and keeps finding my api despite the fact that I proxies it through server less requests and is just constantly trying authenticate themselves. So I need it to stop the user from getting in.

{

    admin off # theres no need for the admin api in railway's environment

    persist_config off # storage isn't persistent anyway

    auto_https off # railway handles https for us, this could in some cases cause issues if left enabled

    # runtime logs

    log {

        format json # set runtime log format to json mode

    }

    # server options

    servers {

        trusted_proxies static private_ranges # trust railway's proxy

    }

}

{$MAIN_DOMAIN}:{$PORT} {

    respond " Server is working! Time: {time.now.unix}"

}

Above isn't the ideal configuration but I'm just trying to test to see if I can just get a response MAIN_DOMAIN just doesn't work

Solved$10 Bounty

2 Replies

railway[bot]

6 days ago

Our team is working on getting back to you as soon as possible. In the meantime, we've found the following might help you get unlocked faster:

If you find the answer from one of these, please let us know by solving the thread! Otherwise, we’ll be in touch.


Hi, man

Railway terminates HTTPS before forwarding traffic, so Caddy only sees plain HTTP. When you visit your site with https:// Caddy expects TLS but receives HTTP and logs “Client sent an HTTP request to an HTTPS server.”

You need to tell Caddy to only speak HTTP, not just turn off auto_https. Change your site address to include the http:// scheme. For example:

http://your-domain.com:1234 {
reverse_proxy localhost:8000
}


Status changed to Solved chandrika 5 days ago