SWAG unable to pass "real" IP address?

Hello.

I’m running the latest SWAG via Docker Desktop (under Linux/Fedora), and I just can’t get the real IP address for connections going through the proxy. All I get is the container IP address (192.168.65.1).

My compose file looks like this:

services:
  swag:
    image: lscr.io/linuxserver/swag
    container_name: swag
    cap_add:
      - NET_ADMIN
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=America/Toronto
      - URL=mydomain.com
      - SUBDOMAINS=mysubdomain,
      - VALIDATION=http
      - ONLY_SUBDOMAINS=true
      - STAGING=false
      - DISABLE_F2B=true
      - EMAIL=myemail@mydomain.com
    volumes:
      - /home/myusername/Documents/Docker/swag/config:/config
    ports:
      - 443:443
      - 80:80
    restart: unless-stopped

The proxy’s config looks like this (this points to a server running a native service on port 80, not another container):

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

    server_name mysubdomain.mydomain.com;

    include /config/nginx/ssl.conf;

    client_max_body_size 0;

    location / {
        include /config/nginx/proxy.conf;
        include /config/nginx/resolver.conf;
        set $upstream_app 10.20.55.25;
        set $upstream_port 80;
        set $upstream_proto http;
        proxy_pass $upstream_proto://$upstream_app:$upstream_port;
    }
}

I can connect to the server without issue and everything is working like it should. The only issue I have is that all of the access logs show the same IP address for all connections (the container IP address).

How do I get the real ip address for connections to show up in the logs?

Any advice would be appreciated.

Thanks,
Kristin.

the issue you are seeing is likely due to the ADDITIONAL virtualization layer docker desktop adds; it is one of the reasons we do not support or recommend docker desktop on any OS.

Oh, wow! I didn’t realize that! OK, will test on another machine sans Docker Desktop and see if that works! Thanks for the heads-up!

Well, that’s what it was. I’ve spent days searching this online, sifted through endless troubleshooting threads, and never came across the solution being something so simple as this (or even a mention of “are you running Docker Desktop?”). Now I know. I had no idea. Feel so dumb. Thanks for the quick reply on this! Back up and running now, with proper logging intact!

Thanks again,
k.

glad you got it sorted. so you’re tracking one of the “perks” of docker desktop is that the container is virtualized within docker desktop; this extra layer introduces some complexities for users with use cases like yours (and most home labbers) but it’s great for the development side of things. Have fun!

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.