Caddy -> Apache reverse proxy trailing slash failure

1. Caddy version (caddy version):


2. How I run Caddy:

Caddy is being used as a reverse-proxy. Apache is listening on port 88.

a. System environment:

CentOS 7, systemd

b. Command:

Paste command here.

c. Service/unit/compose file:

Paste full file contents here.
Make sure backticks stay on their own lines,
and the post looks nice in the preview pane.

d. My complete Caddyfile or JSON config: {
    encode gzip
    log {
        output file /var/log/caddy-access.log
        format json
    tls /root/ /root/
    reverse_proxy /v2ray localhost:9999
    #reverse_proxy {
    reverse_proxy {
        header_up Host {http.reverse_proxy.upstream.hostport}
        header_up X-Real-IP {http.request.remote}
        header_up X-Forwarded-For {http.request.remote}
        header_up X-Forwarded-Port {http.request.port}
        header_up X-Forwarded-Proto {http.request.scheme}

3. The problem I’m having:

If a user types an address, without a trailing slash, into their browser’s address bar, the hand-off from Caddy to Apache fails. For example: a user types: (without trailing slash). They are redirected to: and get an unable to connect browser error. Whereas if the user enters (with trailing slash) they are taken to that URL.

How do I fix this?

4. Error messages and/or full log output:

5. What I already tried:

6. Links to relevant resources:

This line is harmful in this situation. This is telling Apache that the Host is

Please do not use header_up lines you do not understand. None of those are useful in this situation, and those last four are essentially never useful, and often harmful. Caddy sets the appropriate proxy headers automatically.

1 Like

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