Static Ip upstream rewrite to PATH

1. The problem I’m having:

Using Caddy as a proxy to pass requests upstream (docker container Laravel app) as follows:

subdomain.xyz.com {

   handle_path /* {
    rewrite * /api/payments

    reverse_proxy / http://172.20.0.5 {
        header_up Host {host}
        header_up X-Real-IP {remote}
        header_up X-Forwarded-Port {server_port}

        health_timeout 5s
   }
  }
    log {
        level DEBUG
        output file /var/log/caddy/subdomain.xyz.log
    }
}

Not getting any response from Laravel app.
Container nginx logs not seeing the request coming in.

2. Error messages and/or full log output:

2023/05/26 09:05:54.939	info	http.log.access.log1	handled request	{"request": {"remote_ip": "8.273.146.3", "remote_port": "33818", "proto": "HTTP/3.0", "method": "GET", "host": "subdomain.xyz.com", "uri": "/", "headers": {"Cache-Control": ["no-cache"], "Accept": ["text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7"], "Sec-Fetch-Site": ["none"], "Accept-Language": ["en-US,en;q=0.9,pl;q=0.8,de;q=0.7,it;q=0.6"], "User-Agent": ["Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"], "Sec-Fetch-Mode": ["navigate"], "Sec-Fetch-Dest": ["document"], "Accept-Encoding": ["gzip, deflate, br"], "Pragma": ["no-cache"], "Sec-Ch-Ua": ["\"Google Chrome\";v=\"113\", \"Chromium\";v=\"113\", \"Not-A.Brand\";v=\"24\""], "Sec-Ch-Ua-Mobile": ["?0"], "Sec-Ch-Ua-Platform": ["\"Linux\""], "Dnt": ["1"], "Upgrade-Insecure-Requests": ["1"], "Sec-Fetch-User": ["?1"], "Cookie": []}, "tls": {"resumed": true, "version": 772, "cipher_suite": 4865, "proto": "h3", "server_name": "subdomain.xyz.com"}}, "user_id": "", "duration": 0.000058872, "size": 0, "status": 0, "resp_headers": {"Server": ["Caddy"]}}
2023/05/26 09:05:55.757	info	http.log.access.log1	handled request	{"request": {"remote_ip": "8.273.146.3", "remote_port": "33818", "proto": "HTTP/3.0", "method": "GET", "host": "subdomain.xyz.com", "uri": "/favicon.ico", "headers": {"User-Agent": ["Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"], "Sec-Ch-Ua-Platform": ["\"Linux\""], "Sec-Fetch-Mode": ["no-cors"], "Sec-Fetch-Dest": ["image"], "Cookie": [], "Dnt": ["1"], "Accept": ["image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8"], "Accept-Language": ["en-US,en;q=0.9,pl;q=0.8,de;q=0.7,it;q=0.6"], "Pragma": ["no-cache"], "Sec-Ch-Ua": ["\"Google Chrome\";v=\"113\", \"Chromium\";v=\"113\", \"Not-A.Brand\";v=\"24\""], "Sec-Ch-Ua-Mobile": ["?0"], "Sec-Fetch-Site": ["same-origin"], "Referer": ["https://subdomain.xyz.com/"], "Cache-Control": ["no-cache"], "Accept-Encoding": ["gzip, deflate, br"]}, "tls": {"resumed": true, "version": 772, "cipher_suite": 4865, "proto": "h3", "server_name": "subdomain.xyz.com"}}, "user_id": "", "duration": 0.000053632, "size": 0, "status": 0, "resp_headers": {"Server": ["Caddy"]}}

3. Caddy version:

v2.6.4 h1:2hwYqiRwk1tf3VruhMpLcYTg+11fCdr8S3jhNAdnPy8=

4. How I installed and ran Caddy:

sudo caddy start --config Caddyfile --watch

a. System environment:

Ubuntu 22.04.2 LTS
Docker version 23.0.6, build ef23cbc

You’re proxying only https://subdomain.xyz.com/ to your backend. Is that intentional? You might be wanting to proxy all pages. If so, omit the /.

(Also, please note in the future it is against our rules to redact domain names here, as they are often relevant and hiding them only hinders our ability to help.)

Is there a way to upstream to IP/{specific path}? Any hacks for it?

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