Handle_path does not append prefix to in app urls

1. Caddy version (caddy version):

v2.2.1 h1:Q62GWHMtztnvyRU+KPOpw6fNfeCD3SkwH7SfT1Tgt2c=

2. How I run Caddy:

sudo caddy reload
(from the /etc/caddy/ working directory)

a. System environment:

uname -a
4.19.0-10-amd64 #1 SMP Debian 4.19.132-1 (2020-07-24) x86_64 GNU/Linux

b. Command:

paste command here

c. Service/unit/compose file:

paste full file contents here

d. My complete Caddyfile or JSON config:


centuri-engineering.univ-amu.fr {
    root * /var/www/				
    file_server
    reverse_proxy  /clicket/* 127.0.0.1:5001
    reverse_proxy /omero/* 127.0.0.1:4080
    reverse_proxy /saphir/* 127.0.0.1:3838
    reverse_proxy /cataloger/* 127.0.0.1:5000
    redir /shiny /shiny/
    handle_path /shiny* {
	reverse_proxy localhost:8080
	}
}

3. The problem I’m having:

I have several apps running on the same server. As I have not access to the DNS records, I must run each app in a sub-directory (only the subdomain is recorded, not sub-sub-domains).

For the first 3 apps, I changed the app root within the app itself (through an environment variable) - those are flask & django apps running in docker containers) so the reverse_proxys work as every request at the app level contains the matching string.

From reading here and on github, I understand that the better practice is to use the reverse_path directive, which I have to do anyway for the last one (ShinyProxy is a java tool, I cannot change the root url in the configuration).

With the above Caddyfile, requests such as https://centuri-engineering.univ-amu.fr/shiny/login indeed get me to a login page but without any CSS. Filling that page then redirects to https://centuri-engineering.univ-amu.fr/login , which is 404

If I try e.g. https://centuri-engineering.univ-amu.fr/shiny/app it also gets redirected to https://centuri-engineering.univ-amu.fr/login

So my feeling is the outside requests are indeed striped from the shiny prefix, but the shiny prefix is not appended for the redirections within the app.

Do I miss something?

4. Error messages and/or full log output:

No error logs per se

5. What I already tried:

I tried the strip_prefix directive and the handle_path, with various combinations of leading and trailing slashes ^^’

6. Links to relevant resources:

All the entries in github and here seem to point to the above

Thanks a lot for any insight, and that superb piece of software!

Best

Guillaume

This wiki article explains this problem:

1 Like

Thanks a lot, I think I understand, I’ll try to advocate for a wildcard DNS record I think

Best,

Guillaume

This topic was automatically closed after 30 days. New replies are no longer allowed.