Skip to content

Commit 4107a7d

Browse files
committed
ip again again
1 parent b46ae07 commit 4107a7d

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

nginx.conf

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ http {
1515
set_real_ip_from 10.223.0.0/16;
1616
real_ip_header CF-Connecting-IP;
1717

18+
# Map to get the most reliable client IP
19+
map $http_cf_connecting_ip $client_ip {
20+
"" $remote_addr;
21+
default $http_cf_connecting_ip;
22+
}
23+
1824
# Debug logging format to see all IP variables
1925
log_format debug_ips '$remote_addr - $realip_remote_addr - $http_cf_connecting_ip - $http_x_forwarded_for - $http_x_real_ip';
2026
server {
@@ -25,22 +31,22 @@ http {
2531
access_log /dev/stdout debug_ips;
2632

2733
location /lib.min.js {
28-
proxy_set_header X-Real-IP $realip_remote_addr;
34+
proxy_set_header X-Real-IP $client_ip;
2935
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
3036
proxy_set_header X-Forwarded-Host $server_name;
3137
proxy_pass https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js;
3238
}
3339

3440
location /lib.js {
35-
proxy_set_header X-Real-IP $realip_remote_addr;
41+
proxy_set_header X-Real-IP $client_ip;
3642
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
3743
proxy_set_header X-Forwarded-Host $server_name;
3844
proxy_pass https://cdn.mxpnl.com/libs/mixpanel-2-latest.js;
3945
}
4046

4147
location /decide {
4248
proxy_set_header Host decide.mixpanel.com;
43-
proxy_set_header X-Real-IP $realip_remote_addr;
49+
proxy_set_header X-Real-IP $client_ip;
4450
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
4551
proxy_set_header X-Forwarded-Host $server_name;
4652
proxy_set_header X-Forwarded-Proto $scheme;
@@ -49,7 +55,7 @@ http {
4955

5056
location / {
5157
proxy_set_header Host api.mixpanel.com;
52-
proxy_set_header X-Real-IP $realip_remote_addr;
58+
proxy_set_header X-Real-IP $client_ip;
5359
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
5460
proxy_set_header X-Forwarded-Host $server_name;
5561
proxy_set_header X-Forwarded-Proto $scheme;

0 commit comments

Comments
 (0)