3 months ago
Hi there,
Is there any way I can preserve "X-Forwarded-Host" header from the origin? Railway rewrites it with its own value, but I'd like to get the original header. I'm using a CDN in front of Railway and I need that header from CDN origin to route requests properly.
As a solution, I exposed service using TCP proxy and set that proxy to the CDN but preferrably I'd like to use a HTTP service so I can have access to metrics in Railway.
Pinned Solution
2 months ago
Can't use header with a different name, unfortunately, since I'm using a 3rd party CDN and i do not have control over that. I think the only viable solution in my case is expose service as TCP unless railway team decides to somehow preserve the headers.
4 Replies
3 months ago
This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.
Status changed to Open brody • 3 months ago
3 months ago
If you check this link (railway util):
https://utilities-us-east.up.railway.app/raw
you can see the X-Real-Ip and the X-Forwarded-For has the real ip, you can use these 2 headers
fra
If you check this link (railway util):https://utilities-us-east.up.railway.app/rawyou can see the X-Real-Ip and the X-Forwarded-For has the real ip, you can use these 2 headers
3 months ago
I'm not sure how that helps
curl -H "x-forwarded-host: example.com" https://utilities-us-east.up.railway.app/raw
GET /raw HTTP/1.1
Host: utilities-us-east.up.railway.app
Accept: */*
Accept-Encoding: gzip
User-Agent: curl/8.12.1
X-Forwarded-For: 45.85.105.21
X-Forwarded-Host: utilities-us-east.up.railway.app
X-Forwarded-Proto: https
X-Railway-Edge: railway/europe-west4-drams3a
X-Railway-Request-Id: xJwO0zg7SeuNy-G0N8N_Fg
X-Real-Ip: 45.85.105.21
X-Request-Start: 1766517603052x-forwarded-host: example.com is not preserved, which i want to keep
2 months ago
I'm sorry, I read host and replied with the ip
my bad, the x-header-* is added in railway gateway so it will always be overwritten by railway, can you explain a bit more what's your goal?
In theory, even if you have a CDN in front you should get the origin host in the x-forwarded-host, if you have a custom logic you might need to use a header with a different name
fra
I'm sorry, I read host and replied with the ip my bad, the x-header-* is added in railway gateway so it will always be overwritten by railway, can you explain a bit more what's your goal?In theory, even if you have a CDN in front you should get the origin host in the x-forwarded-host, if you have a custom logic you might need to use a header with a different name
2 months ago
Can't use header with a different name, unfortunately, since I'm using a 3rd party CDN and i do not have control over that. I think the only viable solution in my case is expose service as TCP unless railway team decides to somehow preserve the headers.
Status changed to Solved sarahkb125 • 2 months ago
