R
Railwayβ€’2y ago
Crafter

Get IP of incoming HTTP request

Is there a way to get incoming HTTP requests? Attempting to get the IP results in the IP of the railway proxy being returned. Is there a header or something I can grab?
28 Replies
Percy
Percyβ€’2y ago
Project ID: N/A
Crafter
CrafterOPβ€’2y ago
N/A
Brody
Brodyβ€’2y ago
Crafter
CrafterOPβ€’2y ago
cool thanks
Brody
Brodyβ€’2y ago
no problem!
Crafter
CrafterOPβ€’2y ago
@Brody Do you know if using a cloudflare proxy affects this?
Brody
Brodyβ€’2y ago
if you use a custom domain with a cloudflare proxy, you will now get a cloudflare IP as the A type, and i am pretty sure thats still not a static ip
Crafter
CrafterOPβ€’2y ago
Railway doesn't replicate the X-Forwarded-For header from Cloudflare? Shame.
Brody
Brodyβ€’2y ago
really? railways proxy doesn't pass cloudflare's X-Forwarded-For header through to its own X-Forwarded-For header?
Crafter
CrafterOPβ€’2y ago
Testing that now. Nevermind. It indeed does.
Crafter
CrafterOPβ€’2y ago
FemboyCDN
FemboyCDN is a free image hosting service.
Brody
Brodyβ€’2y ago
fiber πŸ’€
Crafter
CrafterOPβ€’2y ago
I love Fiber. I like the Express feel.
Brody
Brodyβ€’2y ago
πŸ’€
Crafter
CrafterOPβ€’2y ago
Also it's faster than Gin.
Brody
Brodyβ€’2y ago
stdlib is faster than gin gin is bloat
Crafter
CrafterOPβ€’2y ago
Which is why I use Fiber.
Brody
Brodyβ€’2y ago
just dont try to send or receive large files
Crafter
CrafterOPβ€’2y ago
What happens then?
Brody
Brodyβ€’2y ago
by default fasthttp will buffer it into memory sometimes even doublebuffer want to send a 100mb file to a client? well now your mem usage just increased 200mb
Crafter
CrafterOPβ€’2y ago
Fun. Good thing I cap my files at 10mb.
Brody
Brodyβ€’2y ago
i even speed limit uploads and downloads from the apis, theres no need for that dude with 10gig fiber internet to sap up all the bandwidth
Crafter
CrafterOPβ€’2y ago
Haha.
Brody
Brodyβ€’2y ago
so all good now? fiber has a real ip middleware right
app := fiber.New(fiber.Config{
ProxyHeader: fiber.HeaderXForwardedFor,
})
app := fiber.New(fiber.Config{
ProxyHeader: fiber.HeaderXForwardedFor,
})
thats how its done with fiber
Crafter
CrafterOPβ€’2y ago
I just did this. c.Get("X-Forwarded-For")
Brody
Brodyβ€’2y ago
perfect oh not perfect
Crafter
CrafterOPβ€’2y ago
Fixed.
Brody
Brodyβ€’2y ago
do this, then you can just do c.IP() in a handler
Want results from more Discord servers?
Add your server