fescobar / allure-docker-service-ui

Allure Docker Service UI provides a friendly user interface for frankescobar/allure-docker-service API container.
Apache License 2.0
83 stars 43 forks source link

PREFIX does not change path for static files #7

Open rayjlinden opened 4 years ago

rayjlinden commented 4 years ago

I'm trying to put the ui behind a proxy.

I set URL_PREFIX: "/allureui"

However, the page once it loads is trying to get assets like: /static/js/2.305ecc37.chunk.js

Is there something I can do to serve the assets out the url_prefix as well?

fescobar commented 4 years ago

@rayjlinden what proxy are you using? and what is your configuration? are you using Kubernetes? did you try adding after prefix /allure-docker-service-ui/ like this? http://${IP}:${PORT}/allureui/allure-docker-service-ui/

rayjlinden commented 4 years ago

I'm using caddy2. (caddyserver.com)

I wanted to serve the UI out of a sub dir. I set the env var: URL_PREFIX: "/allureui"

My Caddyfile config looks like this:

        route /env-config.js {
                reverse_proxy http://allureui:5252
        }
        route /static/* {
                reverse_proxy http://allureui:5252
        }
        route /allureui/* {
                jwt

                reverse_proxy http://allureui:5252
        }

I had to add the routes for /static/* and /env-config.js -- then everything worked. However, I would have expected the references to the static assets and env-config.js to also be prefixed with /allureui/

On Tue, Sep 22, 2020 at 2:25 AM fescobar notifications@github.com wrote:

@rayjlinden https://github.com/rayjlinden what proxy are you using? and what is your configuration? are you using Kubernetes?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/fescobar/allure-docker-service-ui/issues/7#issuecomment-696608417, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKE5LWRWG2R2BRWJ4AFPN2TSHBUOZANCNFSM4RVEW4NA .

fescobar commented 4 years ago

@rayjlinden you have to set up a little different when it's a Single Page Aplication (SPA). Fortunately, it's work for you. I will see how can I improve that part because as you said I'm not totally convinced how it's working now.

oleksandr-hyuna commented 3 years ago

Same with Nginx: docker-compose

version: '3'
services:
  allure:
    image: "frankescobar/allure-docker-service"
    environment:
      CHECK_RESULTS_EVERY_SECONDS: 1
      KEEP_HISTORY: 1
      URL_PREFIX: "/allure"
    ports:
      - "5050:5050"
    volumes:
      - /etc/allure/allure-results:/app/allure-results
      - /etc/allure/allure-reports:/app/default-reports
  allure-ui:
    image: "frankescobar/allure-docker-service-ui"
    environment:
      ALLURE_DOCKER_PUBLIC_API_URL: "http://nginx.domain.com"
      ALLURE_DOCKER_PUBLIC_API_URL_PREFIX: "/allure"
      URL_PREFIX: "/allureui"
    ports:
      - "5252:5252"

Works only with separate env-config.js and static route:

    location /allure/ {
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_pass http://allure:5050;
    }
    location /allureui/ {
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_pass http://allure:5252;
    }
    location /env-config.js {
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_pass http://allure:5252;
    }
    location /static/ {
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_pass http://allure:5252;
    }

That's can conflict with my "location /" that is not ok as for me

fescobar commented 3 years ago

Thanks @oleksandr-hyuna for the info. I will use this when I try to fix this problem. It's in the backlog.

sharmau5 commented 3 years ago

Facing the same issue. I am using Istio virtual services and have to map the root / location to the ui to get the static assets to load. A fix will be great as this is not going to work long-term.

    - match:
        - uri:
            prefix: /ids-reports-api
      rewrite:
        uri: /
      route:
        - destination:
            host: ids-reports
            port:
              number: 5050
    - match:
        - uri:
            prefix: /ids-reports-ui
      route:
        - destination:
            host: ids-reports
            port:
              number: 5252
    - match:
        - uri:
            prefix: /
      route:
        - destination:
            host: ids-reports
            port:
              number: 5252
sk-idwell commented 1 year ago

@fescobar There's a base tag in index.html file which makes all links relative to the server root. It appears that it's not really necessary for the app to work. It's elimination can fix this issue.

alb3ric commented 1 year ago

Hello,

Any news about this issue ? I got the same behavior with traefik.

I set this in my docker-compose for allure routing :

 - "traefik.http.routers.allureui.rule=Host(`my.example.com`) && PathPrefix(`/allure/`)"

I set :

  environment :
    - URL_PREFIX: "allure"

But when I connect to my.example.com/allure I have error concerning loading the static files. Is it link to this issue or am I doing something wrong in my docker-compose ?

khanzzirfaniag commented 1 year ago

Hello @fescobar any ETA for the static files for URL_PREFIX to work? I have deployed on k8s and it fails for static path.

image

as other UI works with correctly having base url_prefix

image
fescobar commented 1 year ago

Hi everybody You can try forking the project and trying your solution. This is not a simple bug. It depends on how you set up the configuration in your environment. A few years ago Kubernetes didn't support Static webpages properly, you needed to hack a little to have that working. At the moment not sure if Kubernetes supports that properly. I think the proper way to fix that it's moving from ReactJS (Single Server Application) to NextJS (Server Side Rendering) which is a big task. If someone can find a solution is welcome.