NginxProxyManager / nginx-proxy-manager

Docker container for managing Nginx proxy hosts with a simple, powerful interface
https://nginxproxymanager.com
MIT License
23.46k stars 2.72k forks source link

Can't show the Client real ip #2573

Open g-marinov opened 1 year ago

g-marinov commented 1 year ago

Describe the bug No matter what I did can't see the client real IP, I can see only the docker IP.

LOGS: web-address is the webpage I'm accessing

[31/Jan/2023:08:51:36 +0000] - 200 200 - GET http web-address "/openapi.json" [Client 192.168.208.1] [Length 1384] [Gzip -] [Sent-to 192.168.2.140] "Mozilla/5.0 (Linux; Android 12; SM-S901B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Mobile Safari/537.36" "http://web-address/docs"
[31/Jan/2023:08:51:39 +0000] - 200 200 - GET http web-address "/X-Real-IP" [Client 192.168.208.1] [Length 27] [Gzip -] [Sent-to 192.168.2.140] "Mozilla/5.0 (Linux; Android 12; SM-S901B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Mobile Safari/537.36" "http://web-address/docs"
[31/Jan/2023:08:51:46 +0000] - 200 200 - GET http web-address "/X-Forwarded-For" [Client 192.168.208.1] [Length 27] [Gzip -] [Sent-to 192.168.2.140] "Mozilla/5.0 (Linux; Android 12; SM-S901B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Mobile Safari/537.36" "http://web-address/docs"

Nginx Proxy Manager Version jc21/nginx-proxy-manager:latest

version: '3'
services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    restart: unless-stopped
    ports:
      - '80:80'
      - '443:443'
      - '81:81'
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt

Operating System Docker Desktop

Additional context FastApi

from typing import Union
from fastapi import FastAPI, Header, Request

app = FastAPI()

@app.get("/X-Forwarded-For")
async def root(request: Request):
    my_header = request.headers.get('X-Forwarded-For')
    return {"message": my_header}

@app.get("/X-Real-IP")
async def root(request: Request):
    my_header = request.headers.get('X-Real-IP')
    return {"message": my_header}
navhawk80 commented 1 year ago

Please del

g-marinov commented 1 year ago

Hi navhawk80, this doesn't fix the problem. After a few hours of tests, I finally find the problem. The problem is the Windows 🥇, it's not only nginx, traefik has the same issue ... When I switch to my ubuntu server everything was working well.

navhawk80 commented 1 year ago

Hi, Please disregard info I mentioned above. Real fix was the script from here https://gist.github.com/pedrolamas/db809a2b9112166da4a2dbf8e3a72ae9 I put it into startup on my synology and now in LOGs external IPs are beaing reconnized correctly.

github-actions[bot] commented 10 months ago

Issue is now considered stale. If you want to keep it open, please comment :+1: