Skip to content

Commit 71ae218

Browse files
author
Jonathan Visser
committed
Add whitelisting based on User Agent and IP
1 parent 04caffc commit 71ae218

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

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

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

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

0 commit comments

Comments
 (0)