Does Railway override
X-Forwarded-Host
header?

shxkm
PRO

6 months ago

I'm using Caddy (hosted elsewhere) as a reverse-proxy to my railway app (Caddy is pointing to a domain which is CNAMING to Railway).

Despite my logs showing that Caddy is passing through the correct X-Forwarded-Host header, my Django application is showing that it's the CNAMED domain. Is it because Railway overrides this header, or because Railway itself is sort of a reverse-proxy? should I point Caddy directly to the railway-production URL?

Solved

0 Replies

shxkm
PRO

6 months ago

N/A


shxkm
PRO

6 months ago

If I send a custom header, like X-Original-Host, then I see the desired value. Sample from Caddyfile:

:443 {
    tls {
        on_demand
    }

    reverse_proxy https://railwaydomain.com {
        trusted_proxies 0.0.0.0/0 --> this is bad, only for verification
        header_up Host railwaydomain.com
        header_up X-Forwarded-Host {http.request.host} ---> arrived as railwaydomain.com
        header_up X-Original-Host {http.request.host} ---> arrived as original domain
        header_up X-Real-IP {remote_host}
    }
}

6 months ago

According to this thread, the X-Forwarded-For header is partially overwritten by Railway. Give this a read and see if it helps you out

https://help.railway.com/questions/edge-proxy-x-forwarded-for-and-x-real-ip-c5a50049


6 months ago

I'm not seeing any resolved threads referencing the X Forwarded Host header. That may be completely overwritten by Railway



shxkm
PRO

6 months ago

Unfortunately that doesn't really answer the question. At this point I'm pretty sure Railway overrides this header, which is a bit of a bummer.


6 months ago

I'll call in the team here, they likely won't respond until Monday, just a heads up.


6 months ago

!t


6 months ago

This thread has been escalated to the Railway team.

Status changed to Awaiting Railway Response adam 6 months ago


6 months ago

yes we would overwrite the x-forwarded-host


maddsua
HOBBY

6 months ago

Indeed they do


Status changed to Solved itsrems 6 months ago