ngoduykhanh / wireguard-ui

Wireguard web interface
MIT License
4.25k stars 524 forks source link

Q: How to see connected peers when running wireguard-ui in docker? #238

Closed dev9209 closed 1 year ago

dev9209 commented 2 years ago

Hello,

I've wireguard engine and wireguard-ui running in docker as containers. I've specified WGUI_CONFIG_FILE_PATH for wg0.conf and can use wireguard-ui to create new peers and everything works, but I can't see any of them connected in the web gui (connected peers). Is there anything I can do? Thanks in advance!

dutchco commented 2 years ago

This is documented in the readme. Just follow the docker part, worked for me!

xtr3-m3 commented 2 years ago

I have the same issue like @dev9209 . There is not much information in the Docker Part. Can you tell me, what i need to do exactly. I also have wireguard and wireguard-ui running as docker containers.

Thank you!

Nenodema commented 1 year ago

I have also exactly the same issue, this is my docker-compose file. Users are connected via WireGuard (which is running in Docker on the same host) but nothing shows up in the status page.

version: "3"

services:
  wg:
    image: ngoduykhanh/wireguard-ui:latest
    container_name: wgui
    cap_add:
      - NET_ADMIN
    network_mode: host
    environment:
      - SENDGRID_API_KEY
      - EMAIL_FROM_ADDRESS
      - EMAIL_FROM_NAME
      - SESSION_SECRET
      - WGUI_USERNAME=alpha
      - WGUI_PASSWORD=this-unusual-password
      - WG_CONF_TEMPLATE
      - WGUI_MANAGE_START=true
      - WGUI_MANAGE_RESTART=true
    logging:
      driver: json-file
      options:
        max-size: 50m
    volumes:
      - ./db:/app/db
      - /home/user/docker/wireguard-vpn/config:/etc/wireguard

What have i already tested?

I run the WireGuard server also in Docker (lscr.io/linuxserver/wireguard:latest)

@dutchco could you please describe exactly how you fixed this issue? @ngoduykhanh could you please elaborate?

bytedream commented 1 year ago

There are two ways to make the status page working when having wireguard and wireguard-ui as containers.

1: Set the network_mode on both containers to host (haven't tried myself but according to #317 (comment) this works)

Example ```yaml version: '3' services: wireguard: image: linuxserver/wireguard:latest container_name: wireguard cap_add: - NET_ADMIN network_mode: host volumes: - ./config:/config wireguard-ui: image: ngoduykhanh/wireguard-ui:latest container_name: wireguard-ui depends_on: - wireguard cap_add: - NET_ADMIN network_mode: host environment: - SENDGRID_API_KEY - EMAIL_FROM_ADDRESS - EMAIL_FROM_NAME - SESSION_SECRET - WGUI_USERNAME=alpha - WGUI_PASSWORD=this-unusual-password - WG_CONF_TEMPLATE - WGUI_MANAGE_START=false - WGUI_MANAGE_RESTART=false logging: driver: json-file options: max-size: 50m volumes: - ./db:/app/db - ./config:/etc/wireguard ```

2: Set the network_mode on the wireguard-ui container to service:<name of your wireguard container>

Example ```yaml version: '3' services: wireguard: image: linuxserver/wireguard:latest container_name: wireguard cap_add: - NET_ADMIN volumes: - ./config:/config ports: # port of the wireguard server - 51820:51820/udp # port for wireguard-ui. this must be set here as the `wireguard-ui` container joins the network of this container and hasn't its own network over which it could publish the ports - 5000:5000 wireguard-ui: image: ngoduykhanh/wireguard-ui:latest container_name: wireguard-ui depends_on: - wireguard cap_add: - NET_ADMIN # this is the important line: network_mode: service:wireguard environment: - SENDGRID_API_KEY - EMAIL_FROM_ADDRESS - EMAIL_FROM_NAME - SESSION_SECRET - WGUI_USERNAME=alpha - WGUI_PASSWORD=this-unusual-password - WG_CONF_TEMPLATE - WGUI_MANAGE_START=false - WGUI_MANAGE_RESTART=false logging: driver: json-file options: max-size: 50m volumes: - ./db:/app/db - ./config:/etc/wireguard ```
stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

JorisM commented 4 months ago

I couldn't set it to either of the options suggested by @bytedream due to contraints on my setup.

So I created a small project to get a separate dashboard up and running that shows the status: https://github.com/JorisM/wireguard-status -> works for me for now.