1 |
On Thu, 29 Nov 2012 11:55:17 -0800 |
2 |
Grant <emailgrant@×××××.com> wrote: |
3 |
|
4 |
> >> >> I use apache2 authentication for web users and I would like |
5 |
> >> >> to |
6 |
> >> require |
7 |
> >> >> logins from certain users to be from a certain IP address. |
8 |
> >> >> I experimented with Allow and Require but couldn't find a way |
9 |
> >> >> to |
10 |
> >> restrict |
11 |
> >> >> only certain users. Can this be done via apache2 |
12 |
> >> >> authentication |
13 |
> >> or |
14 |
> >> >> should I use another method? |
15 |
> >> >> |
16 |
> >> >> - Grant |
17 |
> >> > |
18 |
> >> > |
19 |
> >> > very simple via .htaccess |
20 |
> >> > |
21 |
> >> > <Limit GET POST> |
22 |
> >> > order deny,allow |
23 |
> >> > deny from all |
24 |
> >> > allow from IP_address |
25 |
> >> > </Limit> |
26 |
> >> > |
27 |
> >> > AuthName "restricted stuff" |
28 |
> >> > AuthType Basic |
29 |
> >> > AuthUserFile /etc/apache2/users |
30 |
> >> > require user webmaster |
31 |
> >> |
32 |
> >> I think that will require any usernames specified to come from |
33 |
> >> IP_address. I'm trying to allow certain usernames to come from |
34 |
> >> any IP, and restrict other usernames to a certain IP. Can that be |
35 |
> >> done via .htaccess? |
36 |
> >> |
37 |
> >> - Grant |
38 |
> > |
39 |
> > |
40 |
> > You originally wanted "...logins from certain users to be from a |
41 |
> > certain |
42 |
> IP address" |
43 |
> > Now, you want from "any IP" In this case just restrict users with: |
44 |
> > |
45 |
> > |
46 |
> > AuthName "restricted stuff" |
47 |
> > AuthType Basic |
48 |
> > AuthUserFile /etc/apache2/users |
49 |
> > require user webmaster |
50 |
> > |
51 |
> > Just assign "password and user" from root: |
52 |
> > # htpasswd2 -c /etc/apache2/users your-user-name |
53 |
> |
54 |
> I'm sorry I haven't been clear about this. Sometimes an example is |
55 |
> the best way. |
56 |
> |
57 |
> I want users jack and jill to be able to access the web content from |
58 |
> any IP address, and I want users john and jacob to be able to access |
59 |
> the web content only if they are coming from a certain IP address. I |
60 |
> don't want anyone else to have access. |
61 |
> |
62 |
> - Grant |
63 |
|
64 |
Run two vhosts that deliver the same content from the same DocumentRoot |
65 |
|
66 |
One has jack and jill as users in htpasswd with no acls in place |
67 |
The other has john and jacob as users in a different htpasswd with IP |
68 |
acls in place |
69 |
|
70 |
Trying to specify access rules to a group of users and not to other |
71 |
users all in the same context is a problem that will drive you nuts in a |
72 |
day. Rather side-step it entirely by applying your rules globaly to two |
73 |
different things. |
74 |
|
75 |
-- |
76 |
Alan McKinnon |
77 |
alan.mckinnon@×××××.com |