Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverse proxy configuration with Traefik2 #3302

Open
aronmgv opened this issue Jun 22, 2021 · 7 comments
Open

Reverse proxy configuration with Traefik2 #3302

aronmgv opened this issue Jun 22, 2021 · 7 comments
Labels

Comments

@aronmgv
Copy link

aronmgv commented Jun 22, 2021

Hello,

I am having quite troubles with configuring reverse proxy for Zoenminder (v1.36.4).

I am using addPrefix to add /zm/ in background so user can directly access Zoneminder on its subdomain cam.example.com. This partially works - I am getting the web page, but some styles are missing and stream is not working. After some time I get redirected to cam.example.com/zm/index.php - which does not exist on subdomain context.. If I tries to load cam.example.com/index.php it succeeds.

Direct access:

image

vs

Subdomain access:

image

For the streams its the same scenario:

image

Traefik2 configuration for the reverse proxy zoneminder:

http:

  routers:
    zoneminder.example.com:
      priority: 1
      entryPoints:
        - websecure
      rule: Host(`cam.example.com`)
      service: zoneminder.example.com
      middlewares:
        - zoneminder.example.com+addPrefix
        #- zoneminder.example.com+replacePathRegex

  services:
    zoneminder.example.com:
      loadBalancer:
        passHostHeader: true
        servers:
          - url: 'http://192.168.255.12:50191'

  middlewares:
    zoneminder.example.com+addPrefix:
      addPrefix:
        prefix: /zm
    zoneminder.example.com+replacePathRegex:
      replacePathRegex:
        regex: "/zm/index(.+)"
        replacement: "/index$1"

Any directions will be appreciated. Thanks, Michal

@welcome
Copy link

welcome bot commented Jun 22, 2021

Thanks for opening your first issue here! Just a reminder, this forum is for Bug Reports only. Be sure to follow the issue template!

@zombielinux
Copy link

I have been having the same problem for quite some time, but to a greater extent.

I have traefik2 set up properly (works with other services) and multiple ZM servers in a multi-server configuration on top of docker swarm. Live streams do not work because of some redirecting that is done to a host that is not accessible from outside the docker network. Likewise, the API access also fails.

I am inclined to believe at this point that unless you are running a single instance of ZM on non-swarm docker, you are unlikely to be successful.

@aronmgv
Copy link
Author

aronmgv commented Jun 22, 2021

@zombielinux actually this is my scenario. Just single instance on non-swarm docker.

Similar deployment has also the Guacamole project. Where you have apache server hosting the app on the prefix /guacamole. Here adding just addPrefix: /guacamole works 100%..

@michael-robbins
Copy link

So I tried this as well a while back and it never worked for me, instead I used a redirect to solve this, and it's been fine for me (users going to the parent page are nicely redirected automatically):

      traefik.http.routers.zoneminder.middlewares: "zoneminder-redir"
      traefik.http.middlewares.zoneminder-redir.redirectregex.regex: "^https:\\/\\/([^\\/]+)\\/?$"
      traefik.http.middlewares.zoneminder-redir.redirectregex.replacement: "https://$1/zm/"
@aronmgv
Copy link
Author

aronmgv commented Jun 30, 2021

@michael-robbins Tried it as well using different pattern and didnt work:

        regex: "^https?://cam.example.com/(.*)"
        replacement: "https://cam.example.com/zm/"

Yours works for me:

        regex: "^https?://([^/]+)/?$"
        replacement: "https://$1/zm/"

Mind explaining me this part: ([^/]+)/? please? Appreciate! Michal

EDIT: I think I get it now.. we strictly just match the FQDN - in other words anything between / sub3.sub2.sub1.dom.com / and this forcibly has applied /zm/ path segment.. Haven't yet seen such one.. Thanks again.

@michael-robbins
Copy link

Not gonna lie, I just copied it off another GitHub comment somewhere lol

But yes it's just another way to match the domain!

@stale
Copy link

stale bot commented Apr 16, 2022

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.

@stale stale bot added the stale label Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 participants