0

I am using apache 2.4.56 and my site is hosted on Google Cloud Compute. "Require ip ip-number" works for /var/www/html/index.html like mysite.com but it doesn't work for mysite.com/cgi-bin/list_directory_1.cgi?directory=%2CBrasil&submit_directory= In the second case, anybody can access it. This is what I have in the apache configuration file:

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require ip 107.217.8.189
</Directory>

My scripts are in /usr/lib/cgi-bin. How do I allow just one IP to access my scripts?

Thanks!

1 Answers1

0

You configured the authentication in the context <Directory /var/www/>, so it only applies to files in /var/www. The cgi-bin directory is not inside that directory, so the authentication does not apply.

You should move it to a <Location> context.

<Location />
    Require ip 107.217.8.189
</Location>
Gerald Schneider
  • 23,274
  • 8
  • 57
  • 89
  • It worked. I placed this directive inside apache2.conf. Is this the correct place? Also, why does "" require a "/>" at the end instead of just ""? Thanks! – Marcos Camargo May 25 '23 at 14:30
  • There are various places, depending on your needs. If you place it inside a `` it will only apply to it, if you place it outside it will apply to all VirtualHosts (if not overridden inside of one). For details see [the documentation](https://httpd.apache.org/docs/2.4/mod/core.html#location). – Gerald Schneider May 25 '23 at 14:49