You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 14, 2025. It is now read-only.
By using the `iprepd` client in `iprepd-nginx`, you can configure nginx to check the reputation of an incoming client IP within `iprepd`. With
14
+
this reputation, `iprepd-nginx` will attach up to three HTTP headers on the request that is then forwarded to your application and can reject
15
+
requests that are below the configured threshold.
16
+
17
+
These three headers are:
18
+
19
+
| Header | Values | Description |
20
+
|---|---|---|
21
+
| X-Foxsec-IP-Reputation | int (0-100) | Reputation score returned by iprepd |
22
+
| X-Foxsec-IP-Reputation-Below-Threshold | boolean ('true'/'false') | Whether the reputation is below the configured threshold |
23
+
| X-Foxsec-Block | boolean ('true'/'false') | High-level whether the request should be blocked (subject to change on what this means) |
24
+
25
+
As well, `iprepd-nginx` is designed to fail open and prefer performance to accuracy. The preference of performance to accuracy can be changed a bit as an
26
+
operator, but only to a certain extent (discussed further below).
statsd_port = tonumber(os.getenv("STATSD_PORT")) or 8125,
35
-
statsd_max_buffer_count = tonumber(os.getenv("STATSD_MAX_BUFFER_COUNT")) or 100,
36
-
statsd_flush_timer = tonumber(os.getenv("STATSD_FLUSH_TIMER")) or 5,
37
-
dont_block = tonumber(os.getenv("DONT_BLOCK")) or 0,
38
-
verbose = tonumber(os.getenv("VERBOSE")) or 0,
39
-
whitelist = {},
40
-
})
41
-
}
42
+
### Prerequisites
42
43
43
-
init_worker_by_lua_block {
44
-
client:config_flush_timer()
45
-
}
44
+
*[iprepd](https://github.com/mozilla-services/iprepd), preferably near your `iprepd-nginx` servers (e.g. within the same region in AWS or GCP)
45
+
* A mechanism for updating iprepd. At Mozilla, this is done by feeding logs from your load balancer, application server, and potentially other locations into our [fraud detection pipeline](https://github.com/mozilla-services/foxsec-pipeline).
46
+
* (optional) A mechanism for collecting statsd metrics.
46
47
47
-
server {
48
-
listen 80;
49
-
root /dev/null;
50
-
error_page 500 502 503 504 /50x.html;
48
+
### Note on Performance
51
49
52
-
location = /50x.html {
53
-
root /usr/local/openresty/nginx/html/;
54
-
}
50
+
A core requirement for iprepd-nginx is that it will add no more than 10ms of latency to requests. Of the mechanisms in place to accomplish this, as an operator there are a few you should be aware of:
55
51
56
-
location = /health {
57
-
return 200;
58
-
access_log off;
59
-
}
52
+
#### Heavy use of caching of responses from iprepd
53
+
By default, iprepd-nginx will cache all non-error responses from iprepd for 30 seconds. It is a good idea to cache errors in production, which is done by enabling `cache_errors` (discussed further below). As well, you may want to lengthen the cache ttl.
By default, iprepd-nginx’s request to iprepd will timeout after 10ms. This should not be increased in production, and may be worth reducing if the network design can support it.
* Make sure iprepd-nginx is seeing the real client IP. You will usually need to use something like [ngx_http_realip_module](https://nginx.org/en/docs/http/ngx_http_realip_module.html), and confirm that it is configured correctly.
192
+
193
+
145
194
## Running locally
146
195
147
-
Create a `.env` file in this repo with the needed environment variables (documentaion below).
196
+
Create a `.env` file in this repo with the needed environment variables (documentation below).
0 commit comments