bugy / script-server

Web UI for your scripts with execution management
Other
1.62k stars 250 forks source link

Ingress/Traefik and redirections #638

Open di-effe opened 1 year ago

di-effe commented 1 year ago

Hi, I am running the docker image in a Kubernetes cluster and configured the Ingresss/Traefik to expose the service on something like https://mydomain/ops/portal/script-server

My problem is how to manage/adapt the default redirections. For example by default the code is trying to redirect from

https://mydomain/ops/portal/script-server/ to https://mydomain/index.html So far I was able to work around the problem bookmarking https://mydomain/ops/portal/script-server/login.html?next=%2Fops/portal/script-server/index.html#/ but it's not an optimal solution

I also played a litte around the src/web/server.py and src/web/web_auth_utilis.py but somehow I was only able to create infinite redirections and to crash the pod :D

Any suggestions? Cheers

bugy commented 1 year ago

Hi @di-effe, unfortunately, I never worked with Traefik. But you need to configure it for redirects, so it replaces paths properly in both directions (from user to server, and from server to user). I.e. when you do "login", script server responds with a new location: image

Your proxy should replace this location on the fly according to routing rules (i.e. add ops/portal/script-server path in this case)

Here are examples for apache server/nginx: https://github.com/bugy/script-server/wiki/Reverse-Proxy-setup. The important part there are ProxyPass and ProxyPassReverse. I don't know what would be an alternative in Traefik.

di-effe commented 1 year ago

Yeah I am trying to understand what is wrong in that traefik config. I hoped to cheat setting some kind of base url variable somewhere and close the case :)

bugy commented 1 year ago

Unfortunately, there is no such option in script server. Is the problem happening on login for you? Or also in some other cases?

di-effe commented 1 year ago

I think it's 2 different issues. The first one is the default redirect from / to ./index.html because it ignores the new additional path in the url. As wrote before it tries to redirect from /ops/portal/scriptserver/ to /index.html. That I might be able to solve with Traefik when I understand how the damn thing works :D

The second issue might be related to the same cause, but it happens when the ?next= is created, because the path is something like login.html?next=/index.html#/ and that, again, redirects to the base url.

No worries, sooner or later I'll figured it out :)

treeol commented 9 months ago

Hi there @di-effe

Any success on your part?

I too have an instance running behind traefik and loading it in an iframe on another service and need to rewrite/re-route the requests properly.

This worked well until I migrated from apache to traefik, for some reason I can't achieve the same results. It's working now with some workarounds.

@bugy

What definitely would make life easier is, if we would be able to set the base path of the script-server instance.

For example if I can define the base path to /script-server instead of /, then the path-rerouting/rewriting with multiple proxies in between would be at least in my case very simple.