tobychui / zoraxy

A general purpose HTTP reverse proxy and forwarding tool. Now written in Go!
https://zoraxy.aroz.org
GNU Affero General Public License v3.0
3.05k stars 184 forks source link

[BUG] No login possible, when hosting multiple Instances in Docker on same IP (different Ports) #340

Closed sailor-ITlab closed 4 weeks ago

sailor-ITlab commented 1 month ago

Describe the bug When I create multiple zoraxy Docker Containers on the same Host (=same IP, but different Ports) I get login Errors, when I open both Management-Tabs (in the same Browser instance) and try to login or register there.

To Reproduce Steps to reproduce the behavior:

  1. Create two Docker Containers for zoraxy (change Public facind Ports) `services: zoraxy: image: zoraxydocker/zoraxy:latest container_name: zoraxy-1 restart: unless-stopped ports:
    • 80:80
    • 443:443
    • 8001:8000 volumes:
    • /path/to/zoraxy-1/zoraxy/config/:/opt/zoraxy/config/
    • /path/to/zoraxy-1/zerotier/config/:/var/lib/zerotier-one/
    • /etc/localtime:/etc/localtime environment: FASTGEOIP: "true" ZEROTIER: "true"`
  2. Open both Management Pages (example IP:8001 and IP: 8002)
  3. Log in to the first page (Also Registering is not posible)
  4. Try to log in to the second page. You should get an Error Message ("Something went wrong.")

Expected behavior Both Websites should be able to login.

Browser (if it is a bug appears on the UI section of the system):

Host Environment (please complete the following information):

Additional context Add any other context about the problem here.

tobychui commented 1 month ago

@sailor-ITlab Login function require cookies, and as both Zoraxy instance have different UUID (and thus, different cookie encryption key), cookie just does't work correctly in your setup. You can try to access both instances in two different browser (e.g. Chrome & Firefox) or setup two different hostnames / domains for your instance and access them via hostnames / domain instead.

See here for more technical details.

sailor-ITlab commented 1 month ago

Ok thanks, I thought maybe you could add an specific variable to the cookie data and the instance (like an uuid), to sort the instances. Then you could have two instances running on the same IP.

tobychui commented 4 weeks ago

maybe you could add an specific variable to the cookie data and the instance (like an uuid), to sort the instances.

Well this use cases are rarely seen and I don't see this specific change is needed. For your use case, try setup a local hostname for each of your instances (e.g. zr1.internal.:8000 and zr2.internal.:8001) and connect it with a domain instead.