forked from mixpanel/tracking-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnginx.conf
More file actions
101 lines (88 loc) · 3.91 KB
/
nginx.conf
File metadata and controls
101 lines (88 loc) · 3.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
events {}
http {
# Cloudflare real IP configuration
set_real_ip_from 173.245.48.0/20;
set_real_ip_from 103.21.244.0/22;
set_real_ip_from 141.101.64.0/18;
set_real_ip_from 108.162.192.0/18;
set_real_ip_from 190.93.240.0/20;
set_real_ip_from 188.114.96.0/20;
set_real_ip_from 198.41.128.0/17;
set_real_ip_from 162.158.0.0/15;
set_real_ip_from 104.16.0.0/13;
set_real_ip_from 172.64.0.0/13;
# Render.com internal IPs (10.223.x.x range)
set_real_ip_from 10.223.0.0/16;
real_ip_header CF-Connecting-IP;
# Map to get the most reliable client IP
map $http_cf_connecting_ip $client_ip {
"" $remote_addr;
default $http_cf_connecting_ip;
}
# Map to block abusive IPs - use client_ip which is already mapped from CF header
map $client_ip $blocked_ip {
default 0;
152.70.106.67 1;
}
# Debug logging format to see all IP variables
log_format debug_ips '$remote_addr - $realip_remote_addr - $http_cf_connecting_ip - $http_x_forwarded_for - $http_x_real_ip';
server {
listen 80 default backlog=16384;
listen [::]:80 default backlog=16384;
# Enable debug logging
access_log /dev/stdout debug_ips;
# Block abusive IPs - check at server level before any location processing
if ($blocked_ip) {
return 403 "Blocked";
}
location /lib.min.js {
proxy_set_header X-Real-IP $client_ip;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_pass https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js;
}
location /lib.js {
proxy_set_header X-Real-IP $client_ip;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_pass https://cdn.mxpnl.com/libs/mixpanel-2-latest.js;
}
location /decide {
# Block abusive IPs at location level as well
if ($blocked_ip) {
return 403 "Blocked";
}
proxy_set_header Host decide.mixpanel.com;
proxy_set_header X-Real-IP $client_ip;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass https://decide.mixpanel.com/decide;
}
location / {
# Block abusive IPs at location level as well
if ($blocked_ip) {
return 403 "Blocked";
}
proxy_set_header Host api.mixpanel.com;
proxy_set_header X-Real-IP $client_ip;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Forwarded-Proto $scheme;
# Comprehensive debug headers
proxy_set_header X-Debug-RemoteAddr $remote_addr;
proxy_set_header X-Debug-RealIP $realip_remote_addr;
proxy_set_header X-Debug-CFConnectingIP $http_cf_connecting_ip;
proxy_set_header X-Debug-ClientIP $client_ip;
proxy_set_header X-Debug-BlockedIP $blocked_ip;
proxy_set_header X-Debug-XForwardedFor $http_x_forwarded_for;
proxy_set_header X-Debug-XRealIP $http_x_real_ip;
proxy_set_header X-Debug-UserAgent $http_user_agent;
proxy_set_header X-Debug-Referer $http_referer;
proxy_set_header X-Debug-TrueClientIP $http_true_client_ip;
proxy_set_header X-Debug-XForwardedForOriginal $http_x_forwarded_for_original;
proxy_set_header X-Debug-AllHeaders "$http_user_agent $http_referer $http_cf_connecting_ip $http_x_forwarded_for $http_x_real_ip $http_true_client_ip";
proxy_pass https://api.mixpanel.com/;
}
}
}