Traefik routing issues

Hi, I am actually wanting to deploy a GLPI service in my traefik managed docker platform. Traefik is working fine with normal containers as reverse proxy, but I want to set up a GLPI container using path labels, my labels are as follows:

  - traefik.enable=true
  - traefik.docker.network=nginx-proxy
  - traefik.port=80
  - traefik.frontend.redirect.regex=^(.*)/glpi$$
  - traefik.frontend.redirect.replacement=$$1/glpi/
  - traefik.frontend.rule=HostRegexp:{subdomain:mysubdomain}.mydomain.com;PathPrefix:/glpi;ReplacePathRegex:^/glpi/(.*) /$$1
  - traefik.entrypoint=https

When I hit https://mysubdomain.mydomain.com/glpi I am correctly routed to my GLPI container, but CSS is broken, and al loaded code on the browser targets to mysubdomain.mydomain.com (without the path).

Is it any way to make the path routing fully working? Thanks in advance!

Hi @bcantera ! A few questions to help you:

  • Could elaborate on the "broken CSS" errors please? I suppose the HTML answered by the backend application is providing links to the stylesheets/javascripts. What are these links exactly? absolute? relative?
  • Is there a particular reason that you are not using PathPrefixStrip as the frontend rule (instead of the combination of Path + ReplacePathRegex ? Is it working with a PrefixPath?
  • Could you provide a reproduction case (is there a glpi docker container for example), so we can reproduce the issue locally and help you
    ?

Hi @dduportal, you are right, by broken CSS I mean that the backend gives me links of the resource without the site path at the end.

Here it is a reproduction example with a generic domain, a valid domain must be used to reproduce the situation:

version: "3.4"

services:

#GLPI Container
  glpi:
    container_name: glpi
    depends_on:
      - mysql
    image: diouxx/glpi
    expose:
      - 80
    restart: always
    labels:
      - traefik.enable=true
      - traefik.docker.network=nginx-proxy
      - traefik.port=80
      - traefik.frontend.redirect.regex=^(.*)/glpi$$
      - traefik.frontend.redirect.replacement=$$1/glpi/
      - traefik.frontend.rule=HostRegexp:{subdomain:mysubdomain}.mydomain.com;PathPrefix:/glpi;ReplacePathRegex:^/glpi/(.*) /$$1
      - traefik.entrypoint=https

#Mysql Container
  mysql:
    image: mysql:5.7.23
    container_name: mysql
    hostname: mysql
    environment:
      - MYSQL_ROOT_PASSWORD=password
      - MYSQL_DATABASE=glpidb
      - MYSQL_USER=glpi_user
      - MYSQL_PASSWORD=glpi
    labels:
      - "traefik.enable=false"

networks:
  default:
    external:
      name: nginx-proxy

Hi @bcantera, thanks for these elements.

I was able to reproduce; it looks like that GLPI is not built for supporting hosting behind a context by default.
As you figured out, the HTML generated by GLPI starts with /xxxx,
(exemple <script type="text/javascript" src="/lib/jquery/js/jquery.min.js?v=9.4.3"></script>),
which are assuming the webapp is always served under the root path of the website (aka. /).

I was not able to find any configuration directive for GLPI to make it aware of the path (location/context). But as It's using Apache, you might be able to adapt the configuration with https://httpd.apache.org/docs/2.4/mod/core.html#location maybe (haven't done Apache for years so I won't be able to chime in here).

For information, whatever reverse-proxy will cause the same problem here, unless you are able to modify the body of the HTTP response on the go (and bye bye performances with this). So maybe reaching out the forum / issue tracker of GLPI could be a good point to request such a feature (like an environment variable for configuring behind a prefix maybe?)

Understood, issue https://github.com/glpi-project/glpi/issues/6196 is open now on GLPI repo.

1 Like