2

I have Apache 2.2 running on CentOS 6.4
There is application in / directory and folder where are some files, lets say it is /public.
I need to allow access to / directory to ip1, ip2, ip3 and allow access to /public folder to ip1, ip2, ip3, ip4, ip5. And ip5 and ip4 are not allowed to access to /.
I tried to do it with this config:

<Location / >
    Require ip ip1 ip2 ip3
</Location>
Alias /public /some/path
<Directory /some/path>
    Options +Indexes
    Require ip ip1 ip2 ip3 ip4 ip5
</Directory>


But ip4 and ip5 cannot access /public folder.
How can I grant access to this IP adresses?

UPD1
If I use

<Location /some/path>
Require ip ip1 ...
</Location>

instead of using Alias and Directory, then I have access, but there is no list of files in browser. Seems, that I should use instead, but then I have no access to this directory.

1 Answer 1

3

You define /public as an Alias URL not a Directory. So, configuration doesn't work because Apache doesn't find /public as Directory.

Try change

<Directory /public>
    Options +Indexes
    Require ip ip1, ip2, ip3, ip4, ip5
</Directory>

to

<Location /public>
    Require ip ip1, ip2, ip3, ip4, ip5
</Location>

Note: Option directive doesn't work inside Location directive

As Alternative configuration, you can specify /some/path instead /public in Directory directive

<Directory /some/path>
    Options +Indexes
    Require ip ip1, ip2, ip3, ip4, ip5
</Directory>

UPDATE

You should place IP restriction in Location directive, because the Location will merge after Directory (see the documentation). Updated configuration is

Alias /public /some/path
<Location /public>
    Require ip ip1 ip2 ip3 ip4 ip5
</Location>
<Directory /some/path>
   Options +Indexes
</Directory>
5
  • if I change Directory to Location, then I still cannot access /public folder.
    – erizo
    May 5, 2014 at 16:14
  • Try alternative answer, change /public to a directory
    – masegaloeh
    May 5, 2014 at 21:43
  • Sorry, my mistake. I have edited my configuration. There was directory with /some/path, not with /public.
    – erizo
    May 6, 2014 at 5:48
  • May it be, that <Location / > block access to /public?
    – erizo
    May 6, 2014 at 5:50
  • You are right. Please see my updated answer.
    – masegaloeh
    May 6, 2014 at 6:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .