How can I drop requests with bad hostname

Hello friends,
I’ve deployed a simple django app in fly.io. However I have observed that my application server rececives a lot of HTTP requests to funny hostnames i.e I get errors like Invalid HTTP_HOST header: ‘213.188.215.250:80’. Is there a way to configure fly.io to allow requests only to a particular hostname and drop everything else so they won’t reach my app ?

TIA,
Serafeim

We have a feature coming that will help with this, but I’m not sure when it will be ready. Hopefully soon!

For now, you can prevent a lot of this by configuring http → https redirects in your django app. We drop TLS connections that don’t match the certificate name, so a very early http redirect is a nice way to ditch bad traffic.

1 Like

Thank you @kurt !

Kind regards,
Serafeim