#Blacklisting ip from accessing the server

26 messages · Page 1 of 1 (latest)

hoary condor
#

Hello, I want to only let specific ip access the server. How can I do that using railway?

dark bluffBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

uncut sinewBOT
#

Project ID: N/A

hoary condor
#

N/A

weak spoke
#

good name

hoary condor
#

hahaha

weak spoke
#

but that's something your app would have to do itself, there's no railway firewall

hoary condor
#

Im hosting the server for sending POST requests only but i only want specific addresses to be able to do that

weak spoke
#

that's something your app would have filter itself, there's no railway firewall

hoary condor
#

Do you know if thats possible using java springboot? sorry im kind of new to this

weak spoke
#

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

hoary condor
#

what do you mean?

weak spoke
#

can't explain it any better than that

hoary condor
#

what is the x forwarded for header?

weak spoke
#

that question can be answered with a quick Google search

hoary condor
#

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

weak spoke
#

you'll need to allow local ip's or else railway might think your app is dead

hoary condor
#

By allowing local ips, do you mean adding 127.0.0.1 to the whitelist or do i need to do additional steps?

weak spoke
#

192.168.0.0/16
10.0.0.0/8
127.0.0.1

#

use cidr ranges to check the incoming ip against

hoary condor
#

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

weak spoke
#

correct

hoary condor
#

Everything seems to be working as intended. Thank you so much for your help.

weak spoke
#

no problem!