反向代理不显示客户端 IP

反向代理不显示客户端 IP

我已经设置了一个反向代理,一切似乎都运行正常,但是 nginx 似乎没有正确注册远程访问 IP 地址,并将所有内容记录为来自我的服务器 WAN IP,这不是问题,但是我正在运行的服务之一是 shlink,它需要传递远程 IP 才能记录位置

我在 docker compose 中通过 SWAG docker 运行 nginx,看看这是否有助于解决问题

下面的示例是所有远程请求各种设备,它们都是从服务器 WAN IP 注册的

202.63.68.112 - - [19/May/2022:10:28:57 +1000] "GET /index.php/s/dGZegTxeeeMmro2/download HTTP/2.0" 206 65536 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 15_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Mobile/15E148 Safari/604.1"
202.63.68.112 - - [19/May/2022:10:28:59 +1000] "GET /index.php/s/dGZegTxeeeMmro2/download HTTP/2.0" 206 7302130 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 15_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Mobile/15E148 Safari/604.1"
202.63.68.112 - - [19/May/2022:10:29:01 +1000] "GET /index.php/s/dGZegTxeeeMmro2/download HTTP/2.0" 206 65536 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 15_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Mobile/15E148 Safari/604.1"
202.63.68.112 - - [19/May/2022:10:29:03 +1000] "GET /index.php/s/dGZegTxeeeMmro2/download HTTP/2.0" 206 5045234 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 15_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Mobile/15E148 Safari/604.1"
202.63.68.112 - - [19/May/2022:10:29:03 +1000] "GET /index.php/s/dGZegTxeeeMmro2/download HTTP/2.0" 206 14906904 "-" "Mozilla/5.0 (Linux; Android 12; SM-G981U1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.61 Mobile Safari/537.36"
202.63.68.112 - - [19/May/2022:10:29:05 +1000] "GET /index.php/s/dGZegTxeeeMmro2/download HTTP/2.0" 206 65536 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 15_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Mobile/15E148 Safari/604.1"
202.63.68.112 - - [19/May/2022:10:29:06 +1000] "GET /index.php/s/dGZegTxeeeMmro2/download HTTP/2.0" 206 5041138 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 15_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Mobile/15E148 Safari/604.1"
202.63.68.112 - - [19/May/2022:10:29:08 +1000] "GET /index.php/s/dGZegTxeeeMmro2/download HTTP/2.0" 206 65536 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 15_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Mobile/15E148 Safari/604.1"
202.63.68.112 - - [19/May/2022:10:29:10 +1000] "GET /index.php/s/dGZegTxeeeMmro2/download HTTP/2.0" 206 6204402 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 15_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Mobile/15E148 Safari/604.1"
202.63.68.112 - - [19/May/2022:10:29:10 +1000] "GET /index.php/s/dGZegTxeeeMmro2/download HTTP/2.0" 206 65536 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 15_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Mobile/15E148 Safari/604.1"
202.63.68.112 - - [19/May/2022:10:29:12 +1000] "GET /index.php/s/dGZegTxeeeMmro2/download HTTP/2.0" 206 65536 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 15_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Mobile/15E148 Safari/604.1"
202.63.68.112 - - [19/May/2022:10:29:12 +1000] "GET /index.php/s/dGZegTxeeeMmro2/download HTTP/2.0" 206 3947506 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 15_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Mobile/15E148 Safari/604.1"
202.63.68.112 - - [19/May/2022:10:29:22 +1000] "GET /index.php/s/dGZegTxeeeMmro2/download HTTP/2.0" 206 22035471 "-" "Mozilla/5.0 (Linux; Android 12; SAMSUNG SM-G981U1) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/17.0 Chrome/96.0.4664.104 Mobile Safari/537.36"
202.63.68.112 - - [19/May/2022:10:29:22 +1000] "GET /index.php/s/dGZegTxeeeMmro2/download HTTP/2.0" 499 0 "-" "Mozilla/5.0 (Linux; Android 12; SAMSUNG SM-G981U1) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/17.0 Chrome/96.0.4664.104 Mobile Safari/537.36"
202.63.68.112 - - [19/May/2022:10:29:22 +1000] "GET /index.php/s/dGZegTxeeeMmro2/download HTTP/2.0" 499 0 "-" "Mozilla/5.0 (Linux; Android 12; SAMSUNG SM-G981U1) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/17.0 Chrome/96.0.4664.104 Mobile Safari/537.36"
202.63.68.112 - - [19/May/2022:10:29:22 +1000] "GET /index.php/s/dGZegTxeeeMmro2/download HTTP/2.0" 499 0 "-" "Mozilla/5.0 (Linux; Android 12; SAMSUNG SM-G981U1) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/17.0 Chrome/96.0.4664.104 Mobile Safari/537.36"
202.63.68.112 - - [19/May/2022:10:29:22 +1000] "GET /index.php/s/dGZegTxeeeMmro2/download HTTP/2.0" 499 0 "-" "Mozilla/5.0 (Linux; Android 12; SAMSUNG SM-G981U1) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/17.0 Chrome/96.0.4664.104 Mobile Safari/537.36"
202.63.68.112 - - [19/May/2022:10:29:22 +1000] "GET /index.php/s/dGZegTxeeeMmro2/download HTTP/2.0" 499 0 "-" "Mozilla/5.0 (Linux; Android 12; SAMSUNG SM-G981U1) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/17.0 Chrome/96.0.4664.104 Mobile Safari/537.36"
202.63.68.112 - - [19/May/2022:10:29:23 +1000] "GET /index.php/s/dGZegTxeeeMmro2/download HTTP/2.0" 206 2923535 "-" "Mozilla/5.0 (Linux; Android 12; SAMSUNG SM-G981U1) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/17.0 Chrome/96.0.4664.104 Mobile Safari/537.36"
202.63.68.112 - - [19/May/2022:10:29:23 +1000] "GET /index.php/s/dGZegTxeeeMmro2/download HTTP/2.0" 499 0 "-" "Mozilla/5.0 (Linux; Android 12; SAMSUNG SM-G981U1) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/17.0 Chrome/96.0.4664.104 Mobile Safari/537.36"
202.63.68.112 - - [19/May/2022:10:29:23 +1000] "GET /index.php/s/dGZegTxeeeMmro2/download HTTP/2.0" 499 0 "-" "Mozilla/5.0 (Linux; Android 12; SAMSUNG SM-G981U1) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/17.0 Chrome/96.0.4664.104 Mobile Safari/537.36"
202.63.68.112 - - [19/May/2022:10:29:23 +1000] "GET /index.php/s/dGZegTxeeeMmro2/download HTTP/2.0" 499 0 "-" "Mozilla/5.0 (Linux; Android 12; SAMSUNG SM-G981U1) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/17.0 Chrome/96.0.4664.104 Mobile Safari/537.36"
202.63.68.112 - - [19/May/2022:10:29:23 +1000] "GET /index.php/s/dGZegTxeeeMmro2/download HTTP/2.0" 499 0 "-" "Mozilla/5.0 (Linux; Android 12; SAMSUNG SM-G981U1) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/17.0 Chrome/96.0.4664.104 Mobile Safari/537.36"
202.63.68.112 - - [19/May/2022:10:29:24 +1000] "GET /index.php/s/dGZegTxeeeMmro2/download HTTP/2.0" 499 0 "-" "Mozilla/5.0 (Linux; Android 12; SAMSUNG SM-G981U1) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/17.0 Chrome/96.0.4664.104 Mobile Safari/537.36"
202.63.68.112 - - [19/May/2022:10:29:24 +1000] "GET /index.php/s/dGZegTxeeeMmro2/download HTTP/2.0" 499 0 "-" "Mozilla/5.0 (Linux; Android 12; SAMSUNG SM-G981U1) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/17.0 Chrome/96.0.4664.104 Mobile Safari/537.36"
202.63.68.112 - - [19/May/2022:10:29:24 +1000] "GET /index.php/s/dGZegTxeeeMmro2/download HTTP/2.0" 206 21001752 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 15_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Mobile/15E148 Safari/604.1"
202.63.68.112 - - [19/May/2022:10:29:26 +1000] "GET /index.php/s/dGZegTxeeeMmro2/download HTTP/2.0" 206 4140047 "-" "Mozilla/5.0 (Linux; Android 12; SAMSUNG SM-G981U1) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/17.0 Chrome/96.0.4664.104 Mobile Safari/537.36"

我已在下面的配置中设置了 X 转发:

#### proxy.conf
---------------
# Proxy Connection Settings
proxy_buffers 32 4k;
proxy_connect_timeout 240;
proxy_headers_hash_bucket_size 128;
proxy_headers_hash_max_size 1024;
proxy_http_version 1.1;
proxy_read_timeout 240;
proxy_redirect  http://  $scheme://;
proxy_send_timeout 240;

# Proxy Cache and Cookie Settings
proxy_cache_bypass $cookie_session;
#proxy_cookie_path / "/; Secure"; # enable at your own risk, may break certain apps
proxy_no_cache $cookie_session;

# Proxy Header Settings
proxy_set_header Connection $connection_upgrade;
proxy_set_header Early-Data $ssl_early_data;
proxy_set_header Host $host;
proxy_set_header Proxy "";
proxy_set_header Upgrade $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-Ssl on;
proxy_set_header X-Real-IP $remote_addr;


#### domain.subdomain.conf
---------------

server {
    listen 443 ssl;
    listen [::]:443 ssl;

    server_name domain.au;

    include /config/nginx/ssl.conf;

    client_max_body_size 0;

    location / {
        include /config/nginx/proxy.conf;
        include /config/nginx/resolver.conf;
        set $upstream_app shlink;
        set $upstream_port 8080;
        set $upstream_proto http;
        proxy_pass $upstream_proto://$upstream_app:$upstream_port;

    }


}

知道我做错了什么吗?

相关内容