distribworks / dkron

Dkron - Distributed, fault tolerant job scheduling system https://dkron.io
GNU Lesser General Public License v3.0
4.27k stars 378 forks source link

Does not work in nginx location different than / #291

Closed leoleovich closed 5 years ago

leoleovich commented 7 years ago

Hello:) Thank you very much for the awesome software. We have a requirement to run it in nginx location. For example /dkron. Unfortunately html, returned by dkron, contains absolute paths starting with /. So in this case client, who requests /dkron gets links to css and js assets like /static/... which of course do not exist. As a solution for now I have to overwrite output via nginx like this:

    location /dkron/ {
        proxy_pass     http://dkron-loadbalancer:8080/;
        proxy_redirect / /dkron/;
        sub_filter '"/' '"/dkron/';
        sub_filter '"\/' '"\/dkron/';
        sub_filter_once off;
    }

which is pretty ugly and may not work in the future.

I was thinking to implement something like, Grafana for example, has. See setting root_url - https://github.com/grafana/grafana/blob/bc6a57ce329d831c42b5d9acf80964e2e9a57163/docs/sources/installation/configuration.md#root_url This will let us to specify "absolute url" to return. I can implement it myself, but it might take quite some time and I wanted to be sure you are fine with this idea. And of course I would prefer if owner of the software would implement this :) Thanks!

vcastellm commented 6 years ago

That used to work before migrating to Gin, I could consider bringing it again if there's enough positive votes.

fopina commented 5 years ago

Definitely being able to specify an ENV var or cmd line option to specify the Engine path would be awesome.

As links are relative it almost works, but then redirects (from non-trail slash to slash - for dashboard/, and the other way around - for jobs) proxy_redirect is required and as there is actually that bug in assets path, it also needs the sub_filter mentioned above.

To be clearer on the bug, static path for /dashboard/jobs is wrongly generated as ../../static. That would be correct for /dashboard/jobs/ but as it is redirected to /dashboard/jobs it should only be ../static.

Fixing this small thing would already help :)

vcastellm commented 5 years ago

@fopina the static path you mention is currently fixed.

WRT the possibility to host this in a subpath I will try something.

fopina commented 5 years ago

IMO there's no actual need to support running on a path with that fixed, it is possible to properly/cleanly use the nginx path with proxypass.

Specifying a path could still be useful in the future if absolute URLs start being used somewhere, but at least now I only see relative ones used, so everything works.

AFAIK this issue could be closed :)

vcastellm commented 5 years ago

Great, thx!