Skip to content

Commit 28e2c08

Browse files
authored
Merge pull request #347 from ByteInternet/add-whitelisting-based-on-ip-and-user-agent
Add whitelisting based on User Agent and IP
2 parents 4a52bdf + 650b1b3 commit 28e2c08

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

docs/hypernode-platform/nginx/basic-authentication-on-hypernode-development-plans.md

100644100755
Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ To whitelist an IP address from basic authentication, you can add it to the geo
4848

4949
To find out the IP's that need to be whitelisted, please contact the external service provider, or [check your access logs](../../troubleshooting/performance/general-troubleshooting.md) to see what IP's are accessing the website.
5050

51-
### Whitelist a User Agent
52-
53-
To whitelist a specific user agent you can add it to the User Agent whitelist map in the whitelist file. We suggest whitelisting a specific term, such as the bot name, or the domainname used in the the user agent, using a regex pattern.
54-
5551
### Whitelist an URL
5652

5753
To whitelist a specific URL you can add it to the url whitelist map in the whitelist file. Please note that the whitelist is based on the entire URL, including any arguments. As such, we advise using a regex pattern when whitelisting.
@@ -115,6 +111,23 @@ map $uri_whitelist$ip_whitelist $development_exceptions {
115111
- We use a geo directive to define `$ip_whitelist`, which checks if the visitor's IP address is whitelisted. If so, we set it to 1, otherwise to 0.
116112
- We combine `$uri_whitelist` and `$ip_whitelist` in a new map that defines `$development_exceptions`. Depending on whether the IP address or URI path is whitelisted, access without basic auth is allowed ("off").
117113

114+
### Whitelisting Based on IP and User Agent
115+
116+
To create a whitelist based on two components: URL and User Agent.
117+
In the **nginx** file named **whitelist-development-exception.conf**, you should use the following configuration:
118+
119+
```nginx
120+
geo $ip_whitelist {
121+
default "Development restricted area";
122+
# 1.2.3.4 1; # IP address whitelist
123+
}
124+
125+
map $http_user_agent $development_exceptions {
126+
default $ip_whitelist;
127+
~*(Klaviyo) "off";
128+
}
129+
```
130+
118131
## Troubleshooting
119132

120133
- Google Pagespeed analysis uses the Google bot user agent and can therefore not be used on development nodes.

0 commit comments

Comments
 (0)