Skip to content

Commit ac1a3d2

Browse files
committed
Testing layout
1 parent 0623137 commit ac1a3d2

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

best_practices/webserver/apache.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,27 @@ order: 100
44

55
# Apache
66

7-
## Overview
7+
## === Panel 1
8+
In this article, we'll tackle the problem how we can decide if a visitor should or should not login on a server with basic auht enabled, based on it's IP-adress.
89

9-
=== Panel 1
10+
So what is the result we want to achieve? We want to implement an .htpasswd so visitors need to have a valid login, except when the request came from a whitelisted IP adress.
11+
In that case, no login is asked and you'll be redirected to the site. Like a VIP that would skip a waiting queue for a club.
12+
13+
#### Method 2: Server with varnish enabled
14+
15+
For a server with varnish enabled, is a different approach needed. All requests that go through varnish will pass the header (X-Forwarded-For), but it may contain some tempered information about the visitors IP.
16+
Because of this modification, the request for immediate access will be denied and the visitor will be asked to login. To make sure this won't happen, we'll add a variable for the header that contains the whitelisted IP-adress.
17+
The code below will do the trick:
18+
19+
AuthType Basic AuthName "Restricted Content" AuthUserFile /var/www/user/apache2/.htpasswd # For best practice will we add the IP's to the required list require ip # Only a person with valid credentials will be redirected require valid-user # We create the variables for the header like so (Ip should be written between quotes): SetEnvIF X-Forwarded-For AllowIP # Include the env variable Require env AllowIP
20+
21+
```
22+
location / {
23+
fastcgi_param HTTPS on;
24+
try_files $uri $uri/ /index.php$is_args$args;
25+
auth_basic "Administrator ^`^ys Area";
26+
auth_basic_user_file $MAGE_ROOT/.htpasswd; # Whitelist Ip-adress allow ;
27+
satisfy any;
28+
}
29+
```
1030
===

0 commit comments

Comments
 (0)