Question

How do I set up a django do-managed web app to serve only 1 ip address? seems like there's only firewall feature for droplets

How do I set up a django do-managed web app to serve only 1 ip address? seems like there’s only firewall feature for droplets


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
December 7, 2022

Hey @wafflez180,

Indeed, you can’t attach a cloud firewall to the App Platform.

The best thing to do to get your voice heard regarding this would be to head over to our Product Ideas board and post a new idea, including as much information as possible for what you’d like to see implemented.

https://ideas.digitalocean.com/

Alternatively, you could create a middleware in Django and programmatically reject all of the traffic. For example, define a variable BLOCKED_IPS = ('123.123.123.123',) where you specify the IP that you want to allow. Then here is an example of the middelware that you could use:

   from django.conf import settings
   from django import http

   class BlockedIpMiddleware(object):

   def process_request(self, request):
          if request.META['REMOTE_ADDR'] in settings.BLOCKED_IPS:
             return http.HttpResponseForbidden('<h1>Forbidden</h1>')
   return None

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up