Rewrite or redirect?

1. Caddy version (caddy version):

v2.3.0 h1:fnrqJLa3G5vfxcxmOH/+kJOcunPLhSBnjgIvjXV/QTA=

2. How I run Caddy:

Home Assistant add on.

a. System environment:

System: Home Assistant OS 6.0 (amd64 / generic-x86-64)
Home Assistant Core: 2021.6.6
Home Assistant Supervisor: 2021.06.6

b. Command:

Paste command here.

c. Service/unit/compose file:

d. My complete Caddyfile or JSON config:

send.example.com {
    reverse_proxy http://192.168.1.133:1443/download
}

3. The problem I’m having:

I’ve setup GitHub - timvisee/send: Simple, private file sharing. Mirror of https://gitlab.com/timvisee/send in Docker, exposing it on port 1443. So when a file is uploaded, the URL to share is http://192.168.1.133:1443/download/RANDOM_STRING. It works as expected using local IP addresses. I would like to share these links with family, but I don’t want to give them (and everybody else) the opportunity to upload files themself (no access to 192.168.1.133:1443), thus I would like to basically share send.example.com/RANDOM_STRING which then translates to
http://192.168.1.133:1443/download/RANDOM_STRING.

4. Error messages and/or full log output:

Error during parsing: for now, URLs for proxy upstreams only support scheme, host, and port components

5. What I already tried:

So I’ve found out that I should use either rewrite or redirect to accomplish this.

I did have a go with rewrite (from Attempting to reverse proxy to a folder w/ Caddy 2 - #4 by Whitestrake), but now I get error: Error during parsing: Wrong argument count or unexpected line ending after ‘rewrite’.

send.example.com {
    rewrite /download{uri}
    reverse_proxy http://192.168.1.133:1443/download
}

So what is the correct way to accomplish this?

6. Links to relevant resources:

You’re close. This

Should be

rewrite * /download{uri}
2 Likes

Thanks a lot. You were right.
Unfortunately, the application does not work as intended, the page is not rendered correct.

Can you clarify what this means?

What does it look like? How is it supposed to look like? And are you seeing any errors?

2 Likes

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