1

I have a Django 2.2 web application running on Apache 2.4 Ubuntu 18.04 web server, which has two network interfaces. One network interface is for internet access(eth0) and other one is for local network(eth1).

I need to find a way to restrict access to some pages from each network interface, while some pages still be accessible from both interfaces.

In projects urls.py I have some urls as follows:

url(r'^eth0/', include('eth0.urls')), #accessible to only eth0
url(r'^eth0eth1/', include('eth0eth1.urls')), #accessible by both network interfaces
url(r'^eth1/', include('eth1.urls')), #accessible to only eth1

How can I achieve this by Apache or Django configuration?

1 Answers1

1

I solved the issue with following apache congfiguration.

<Location /eth0/>
   Require ip eth0_subnet_ip
</Location>
<Location /eth0eth1/>
   Require ip eth0_subnet_ip
   Require ip eth1_subnet_ip
</Location>
<Location /eth1/>
   Require ip eth1_subnet_ip
</Location>

Adding these directives into virtual host configuration solved my problem.

  • Note that the `Deny from all` syntax is the [old Apache 2.2 syntax](http://httpd.apache.org/docs/current/upgrading.html), which is only working because `mod_compat` is loaded. You should change that to the `Require all granted/denied` syntax of Apache 2.4. – Gerald Schneider Jul 13 '20 at 08:29
  • Yes you are right, I edited the answer accordingly. – zenprogrammer Jul 13 '20 at 08:52