ppmt
September 30, 2020, 7:52pm
1
Hello,
I have a docker containing ubooquity (a book library). It uses 2 ports (2202 for the library and 2203 for the admin).
For the moment I have used Traefik to be able to access the library but I would like to be able to access the admin part using the same domain (adding /admin at the end of the domain).
I just can't work out how to recognize the /admin and then redirect to the port 2203 of the container.
Is it something that is possible?
What I want:
ubooquity.local -> service with port 2202
ubooquiy.local/admin -> service with port 2203
cakiwi
September 30, 2020, 8:21pm
2
You will need an additional router + rule and a service to show which port is uses.
- "traefik.http.services.service01.loadbalancer.server.port=2203"
If you post your current labels we can show you what to add.
ldez
September 30, 2020, 8:37pm
3
In addition to what @cakiwi said, a quick example:
# https://ubooquity.localhost/ubooquity
# https://ubooquity.localhost/ubooquity/admin
version: '3.7'
services:
traefik:
image: traefik:v2.3.0
command:
- --log.level=INFO
- --api
- --providers.docker.exposedbydefault=false
- --entrypoints.web.address=:80
# global redirect to https
- --entrypoints.web.http.redirections.entryPoint.to=websecure
- --entrypoints.web.http.redirections.entrypoint.scheme=https
- --entrypoints.websecure.address=:443
- --entrypoints.websecure.http.tls=true
ports:
- 80:80
- 443:443
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
labels:
traefik.enable: 'true'
# Dashboard
traefik.http.routers.traefik.rule: Host(`traefik.localhost`)
traefik.http.routers.traefik.entrypoints: web,websecure
traefik.http.routers.traefik.service: api@internal
traefik.http.routers.traefik.middlewares: auth
traefik.http.middlewares.auth.basicauth.users: user:$$apr1$$q8eZFHjF$$Fvmkk//V6Btlaf2i/ju5n/ # user/password
ubooquity:
image: linuxserver/ubooquity
container_name: ubooquity
environment:
- PUID=1000
- PGID=1000
# - TZ=Europe/London
# - MAXMEM=maxmem
# volumes:
# - path to data:/config
# - path to books:/books
# - path to comics:/comics
# - path to raw files:/files
# restart: unless-stopped
labels:
traefik.enable: 'true'
traefik.http.routers.ubooquity.rule: Host(`ubooquity.localhost`)
traefik.http.routers.ubooquity.entrypoints: web,websecure
traefik.http.routers.ubooquity.service: ubooquity
traefik.http.services.ubooquity.loadbalancer.server.port: 2202
traefik.http.routers.ubooquity-admin.rule: Host(`ubooquity.localhost`) && PathPrefix(`/ubooquity/admin`)
traefik.http.routers.ubooquity-admin.entrypoints: web,websecure
traefik.http.routers.ubooquity-admin.service: ubooquity-admin
traefik.http.services.ubooquity-admin.loadbalancer.server.port: 2203
1 Like
ppmt
October 1, 2020, 9:04am
4
Thank you both for your help.
First @cakiwi ere are my actual labels
- "traefik.enable=true"
- "traefik.http.routers.ubooquity.entrypoints=http"
- "traefik.http.routers.ubooquity.rule=Host(`ubooquity.${DOMAINNAME}`)"
- "traefik.http.routers.ubooquity.middlewares=https-redirect"
- "traefik.http.routers.ubooquity-secure.entrypoints=https"
- "traefik.http.routers.ubooquity-secure.rule=Host(`ubooquity.${DOMAINNAME}`)"
- "traefik.http.routers.ubooquity-secure.tls=true"
- "traefik.http.routers.ubooquity-secure.tls.certresolver=letsencrypt"
- "traefik.http.routers.ubooquity-secure.service=ubooquity"
- "traefik.http.services.ubooquity.loadbalancer.server.port=2202"
@ldez , I tried to add your config as below but I must be getting something wrong
- "traefik.http.routers.ubooquity-admin.entrypoints=https"
- "traefik.http.routers.ubooquity-admin.rule=Host(`ubooquity.${DOMAINNAME}`) && PathPrefix(`/admin`)"
- "traefik.http.routers.ubooquity-admin.service=ubooquity-admin"
- "traefik.http.services.ubooquity-admin.loadbalancer.server.port=2203"
Edit: I fixed my config. It was syntax error on my side (mixing 2 different way of writing the labels).
It now works better. Just needs to find the right path for Ubooquity admin page.
ppmt
October 1, 2020, 10:03am
5
With that config loaded it doesn't seems to be going to port 2203. It always go back to the main page on port 2202.
zespri
October 1, 2020, 10:40am
6
Hey @ppmt , did you try the config that ldez provided? I just tried it and it's working perfectly.
ppmt
October 1, 2020, 10:52am
7
@zespri : if you go to /admin you are redirected to the admin page? for me it doesn't do that.
Looking at the log all I can see is port 2202 being used.
Here is the labels I am using
labels:
- "traefik.enable=true"
- "traefik.http.routers.ubooquity.entrypoints=http"
- "traefik.http.routers.ubooquity.rule=Host(`ubooquity.${DOMAINNAME}`)"
- "traefik.http.routers.ubooquity.middlewares=https-redirect"
- "traefik.http.routers.ubooquity-secure.entrypoints=https"
- "traefik.http.routers.ubooquity-secure.rule=Host(`ubooquity.${DOMAINNAME}`)"
- "traefik.http.routers.ubooquity-secure.tls=true"
- "traefik.http.routers.ubooquity-secure.tls.certresolver=letsencrypt"
- "traefik.http.routers.ubooquity-secure.service=ubooquity"
- "traefik.http.services.ubooquity.loadbalancer.server.port=2202"
- "traefik.http.routers.ubooquity-admin.entrypoints=https"
- "traefik.http.routers.ubooquity-admin.rule= Host(`ubooquity.${DOMAINNAME}`) && PathPrefix(`/admin`)"
- "traefik.http.routers.ubooquity-admin.tls=true"
- "traefik.http.routers.ubooquity-admin.tls.certresolver=letsencrypt"
- "traefik.http.routers.ubooquity-admin.service=ubooquity-admin"
- "traefik.http.services.ubooquity-admin.loadbalancer.server.port=2203"
I removed the /ubooquity from the PathPrefix as I don't use it in my ubooquity preference file.
ppmt
October 1, 2020, 2:18pm
8
All is working now. I checked my config again and now all is working.
I have edited my post above with the config that works for me.
Thanks to all of you for your help. Hopefully I have learnt something and will remember it.
I find it difficult to understand the different prefix options. I have read and read the documentation but can't fully understand when to use one or the other.
system
Closed
October 4, 2020, 2:18pm
9
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.