Use URI for reverse proxy

I would like to ask for your help. I don’t know how to set reverse proxy by URI instead of subdomain.

So far I have been using subdomains for reverse proxy on the services running on my local network. I have these proxies where everything works fine:

Configuration:

gitea.blabla.com:3000 {
    reverse_proxy 127.0.0.1:3100
}

nas.blabla.com {
    @allowed remote_ip 192.168.0.0/16
    # PERMIT ALL: @allowed remote_ip 0.0.0.0/0
    handle @allowed {
        reverse_proxy 192.168.1.17:8860 {
          transport http {
            tls
            tls_insecure_skip_verify
          }
        }
      }

    # Fallback for otherwise not matched handles
    handle {
      abort
    }
}


But I would like to set the reverse proxy to work according to URI:

My configuration that doesn’t work:

blabla.com {
    handle_path /gitea {
        reverse_proxy http://127.0.0.1:3100
    }
    handle_path /nas {
        reverse_proxy https://192.168.1.17:8860 {
          transport http {
            tls
            tls_insecure_skip_verify
          }
        }
    }
}

Result:
When I type in the browser https://blabla.com/gitea I get the page with Gitea, but the page is broken. I see texts and fields but without any page design/formatting. When I click on the login I get a blank page with this address https://blabla.com/user/login?redirect_to=%2f.

In the case of NAS https://walda.cz/nas, I get immediately a blank page with the address https://walda.cz/redirect.html?count=0.4314695115592255.

Question:
I would like to ask you if it is possible to use a reverse proxy in this way, if I did some mistake in configuration or it is related to setting on Gitea and NAS, …

Thank you.

Caddy version:

Caddy is running via docker-compose on Raspberry Pi:

❯ cat docker-compose.yaml
version: "3"

services:
 caddy:
    container_name: caddy
    image: caddy:2.6.2
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile:rw
      - ./data:/data
      - ./config:/config
    environment:
      - TZ=Europe/Rome
    restart: always
    ports:
      - 80:80
      - 443:443
    network_mode: "host"

OS:

❯ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian

Howdy @waldauf!

This is the splitting image of something I’ve described as the subfolder problem. We see this issue so frequently that I’ve written a crash course on it here - what it is, why it happens, and what you can do about it:

1 Like

Hi @Whitestrake,

thank you for your answer and for sending the article. I’ll read it and try to find out a solution. If I found out how to set it with subfolders, I’ll send here the solution.

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