最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Nginx - How to get the Real Client ISP instead of Reverse Proxy ISP - Stack Overflow

programmeradmin0浏览0评论

I am having a backend webserver which works based on Nginx is being hidden behind a Reverse Proxy. I have managed to get the IP and Country of the Client but the issue is with the ISP. I need to know the ISP of the client for some security reasons, but I can see only the Reverse Proxy ISP. I believe that the issue is with the Backend Webserver Nginx. Can anyone have a look and advise?

The Setup is as following:

It would be great if you give advises for Caddy or Nginx Proxy Manager as I am more used to them. However, any answer and help is welcomed and appreciated.

Client <---> Domain <---> Cloudflare <---> Reverse Proxy <---> Backend Server

Note: Cloudflare is optional. I can remove it if needed.

Here is the backend Nginx configuration regarding the ISP part:

#ISP CONFIGURATION

    server {
        listen 8805;
        root /home/directory1/directory2/isp/;
        location / {
            allow 127.0.0.1;
            deny all;
        }
        location ~ \.php$ {
            limit_req zone=one burst=8;
            try_files $uri =404;
            fastcgi_index index.php;
            fastcgi_pass php;
            include fastcgi_params;
            fastcgi_buffering on;
            fastcgi_buffers 96 32k;
            fastcgi_buffer_size 32k;
            fastcgi_max_temp_file_size 0;
            fastcgi_keep_conn on;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param SCRIPT_NAME $fastcgi_script_name;

        }
    }
}

I have tried several Reverse Proxies but all gives me the same results. I think that there should be a way to do it as I have seen similar webservers as me with the same configuration which works fine.

I am having a backend webserver which works based on Nginx is being hidden behind a Reverse Proxy. I have managed to get the IP and Country of the Client but the issue is with the ISP. I need to know the ISP of the client for some security reasons, but I can see only the Reverse Proxy ISP. I believe that the issue is with the Backend Webserver Nginx. Can anyone have a look and advise?

The Setup is as following:

It would be great if you give advises for Caddy or Nginx Proxy Manager as I am more used to them. However, any answer and help is welcomed and appreciated.

Client <---> Domain <---> Cloudflare <---> Reverse Proxy <---> Backend Server

Note: Cloudflare is optional. I can remove it if needed.

Here is the backend Nginx configuration regarding the ISP part:

#ISP CONFIGURATION

    server {
        listen 8805;
        root /home/directory1/directory2/isp/;
        location / {
            allow 127.0.0.1;
            deny all;
        }
        location ~ \.php$ {
            limit_req zone=one burst=8;
            try_files $uri =404;
            fastcgi_index index.php;
            fastcgi_pass php;
            include fastcgi_params;
            fastcgi_buffering on;
            fastcgi_buffers 96 32k;
            fastcgi_buffer_size 32k;
            fastcgi_max_temp_file_size 0;
            fastcgi_keep_conn on;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param SCRIPT_NAME $fastcgi_script_name;

        }
    }
}

I have tried several Reverse Proxies but all gives me the same results. I think that there should be a way to do it as I have seen similar webservers as me with the same configuration which works fine.

Share Improve this question asked Nov 17, 2024 at 3:19 AniAni 1
Add a comment  | 

1 Answer 1

Reset to default 0

I think you can add proxy_set_header in location like this:

location / {
    allow 127.0.0.1;
    deny all;
    proxy_set_header   Host             $host;
    proxy_set_header   X-Real-IP        $remote_addr;
    proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
}

then nginx can pass client's host, client's real ip to bacnend server

发布评论

评论列表(0)

  1. 暂无评论