Blacklisting ip from accessing the server

Hello, I want to only let specific ip access the server. How can I do that using railway?
22 Replies
Percy
Percy2y ago
Project ID: N/A
peebucket
peebucket2y ago
N/A
Brody
Brody2y ago
good name
peebucket
peebucket2y ago
hahaha
Brody
Brody2y ago
but that's something your app would have to do itself, there's no railway firewall
peebucket
peebucket2y ago
Im hosting the server for sending POST requests only but i only want specific addresses to be able to do that
Brody
Brody2y ago
that's something your app would have filter itself, there's no railway firewall
peebucket
peebucket2y ago
Do you know if thats possible using java springboot? sorry im kind of new to this
Brody
Brody2y ago
code up a middleware for it, have the middleware only pass requests if the requests come from a local IP address (so railway itself can healthcheck your app) or the single IP that you have whitelisted, it's a few if statements, nothing complicated make sure you are reading the real ip addresses from the X-Forwarded-For header
peebucket
peebucket2y ago
what do you mean?
Brody
Brody2y ago
can't explain it any better than that
peebucket
peebucket2y ago
what is the x forwarded for header?
Brody
Brody2y ago
that question can be answered with a quick Google search
peebucket
peebucket2y ago
youre right okay thanks for your help i think i got it from here, make a file filtering the ip and only pass the requests if the ip matches
Brody
Brody2y ago
you'll need to allow local ip's or else railway might think your app is dead
peebucket
peebucket2y ago
By allowing local ips, do you mean adding 127.0.0.1 to the whitelist or do i need to do additional steps?
Brody
Brody2y ago
192.168.0.0/16 10.0.0.0/8 127.0.0.1 use cidr ranges to check the incoming ip against
peebucket
peebucket2y ago
i am unfamiliar with working with this, but from what i understand, i need to allow the ranges 192.168.0.0/16 ,10.0.0.0/8, 127.0.0.1, as well as the ip addresses i am whitelisting in my program
Brody
Brody2y ago
correct
peebucket
peebucket2y ago
Everything seems to be working as intended. Thank you so much for your help.
Brody
Brody2y ago
no problem!
Jack
Jack2y ago
would personally suggest using cloudflare for access firewalls and etc, esp for ranges
Want results from more Discord servers?
Add your server