xavier-hernandez / goaccess-for-nginxproxymanager

GoAccess Docker Image for Nginx Proxy Manager and more...
https://hub.docker.com/r/xavierh/goaccess-for-nginxproxymanager
MIT License
523 stars 39 forks source link

No real-time log updates when using custom Docker network #125

Closed kmanwar89 closed 1 year ago

kmanwar89 commented 1 year ago

I originally posted this as a response under #69 , but thought it more appropriate to open a new issue.

Thank you for making this image! It's solved my issues with GoAccess ( no matter what I'd do, it wouldn't recognize the format!), however I seem to be having an issue with GoAccess not loading the logs in realtime despite websockets support enabled in NPM. In fact, I enable websockets support with all of my proxy hosts as I add them.

I believe my issue is due to using NPM as the proxy in front of the container, combined with a custom docker network. If I disable the docker network (and expose the ports straight on my host machine), it works in real-time, but if I enable the docker network, the connectivity in GoAccess breaks (it says disconnected and has a grey dot next to the gear icon on the left side of the screen, see screenshot below):

image

In summary:

Working:

Not working:

Both containers are on the same docker network and have connectivity between them:

❯ docker container inspect goaccess | grep IPAddress
            "SecondaryIPAddresses": null,
            "IPAddress": "",
                    "IPAddress": "172.19.0.4",
❯ docker container inspect npm | grep IPAddress
            "SecondaryIPAddresses": null,
            "IPAddress": "",
                    "IPAddress": "172.19.0.16",

Any ideas here?

xavier-hernandez commented 1 year ago

I'll see if I can reproduce it.

kmanwar89 commented 1 year ago

Let me add something - I did a bit more testing and it seems to be NPM itself causing the issues in addition to what I said above.

If I navigate directly to http://\<ip of server>:7880, works perfectly.

If I setup my host in NPM with that same IP, it does not load results (and only show historical logs)

I do not understand what is causing GoAccess to behave differently than the 20 other containers/microservices I'm hosting, but that seems to be the core symptom here.

xavier-hernandez commented 1 year ago

It's working for me. So I put my docker image behind an internal IP on the same network as NPM and it worked. Both NPM and the docker image have an IP associated in the IP range of the following network.

networks: nginx_proxy_manager: ipam: config:

image image

Maybe you want to share your docker-compose file?

kmanwar89 commented 1 year ago

I figured it out - something to do with my advanced configuration (I have goaccess behind Authentik for additional security) is breaking the WebSocket connection, somehow. I don't think this is a flaw with this image; I'll need to investigate which options to tweak. I'll leave my original post below, but I just confirmed my theory by using the proxy host while on the docker network both with and without the Authentik configs - that is definitely what is breaking my connectivity.

Sorry to bother, I'll go ahead and close this issue out. Cheers!

Original text below Hey there, thanks for taking a look! This is a weird one - I have something like 25 different proxy hosts and have never had this issue with any, not sure what it could be.

The docker compose file I shared is the one from the documentation for this image you created: https://github.com/xavier-hernandez/goaccess-for-nginxproxymanager

I selected NPM as my log type, which seems to work. Here's my NPM compose file:

  GNU nano 6.2                              docker-compose.yml                                        
version: '3'
services:
  app:
    image: jc21/nginx-proxy-manager
    container_name: npm
    restart: unless-stopped
    ports:
      - '80:80'
      - '81:81'
      - '443:443'
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
    healthcheck:
      test: ["CMD", "/bin/check-health"]
      interval: 10s
      timeout: 3s

networks:
  default:
    name: docker_prod
    external: true

and my goaccess-for-npm one:

version: '3.3'
services:
    goaccess:
        image: 'xavierh/goaccess-for-nginxproxymanager:latest'
        container_name: goaccess_npm
        restart: always
        ports:
            - '7880:7880'
        environment:
            - TZ=America/New_York
            - SKIP_ARCHIVED_LOGS=True #optional
            - DEBUG=False #optional
            - BASIC_AUTH=True #optional
            - BASIC_AUTH_USERNAME=username #optional
            - BASIC_AUTH_PASSWORD=password #optional   
            - EXCLUDE_IPS=127.0.0.1 #optional - comma delimited 
            - LOG_TYPE=NPM #optional - more information below
#            - LOG_TYPE=NCSA_COMBINED
        volumes:
        - /home/kadar/services/npm/data/logs:/opt/log
#        - /path/to/host/custom:/opt/custom #optional, required if using log_type = CUSTOM

networks:
  default:
    name: docker_prod
    external: true
kmanwar89 commented 1 year ago

For anyone who comes across this in the future:

I added a single line (proxy_set_header Upgrade $http_upgrade;) to the advanced config of my GoAccess proxy host in NPM. This was added under the location /{} stanza. This fixed the issue with WebSockets not working behind Authentik, so now I have both Authentik & native GoAccess authentication protecting this sensitive information - it's great!