Nextjs proxy pass fail into docker network

Hello. When i try to proxy pass into my nextjs app container i have fail with js files and some *.svg with that config

example.com {
    reverse_proxy frontend-dev:3000 {
}

But when i use

example.com {
    reverse_proxy http://172.18.0.2:3000 {
}

compose.yaml Caddy version v2.8.4

services:
  caddy:
    image: caddy:latest
    container_name: caddy
    restart: unless-stopped
    ports:
      - 80:80
      - 443:443
      - 443:443/udp
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - ./caddy_config:/config
      - ./certificates:/data
    networks:
      - dapp

networks:
  dapp:
    name: dapp
    external: true

it works well. I tried different headers but it not solve the problem. Maybe someone suggest me how to resolve or debug it?
Example of fails

Howdy @Alexander, welcome to the Caddy community!

I don’t think Caddy should be generating 404s on its own; I can only assume they’re coming from the upstream app.

You can use the debug global option to get upstream roundtrip logs that can help you see exactly what Caddy sees when it connects upstream on your behalf.

If that doesn’t help you find the issue, could you please fill out the forum’s Help template? It should have populated in your new post editor when you selected the Help category.

1 Like

1. The problem I’m having:

When i try to proxy pass into my nextjs app container i have fail with some *.js files and some *.svg. But when reques to container directly like 123.123.123.123:3000 on server it works well.
When i write in Caddyfile docker container IP address - it works without errors. But when i try docker container DNS name i receive errors.

2. Error messages and/or full log output:


In Caddy logs i see same errors when i try request.

3. Caddy version:

Caddy version v2.8.4 in docker compose

4. How I installed and ran Caddy:

In docker compose file

a. System environment:

uname -a
Linux ip-192-168-15-150 6.8.0-1009-aws #9-Ubuntu SMP Fri May 17 14:39:23 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

b. Command:

docker compose up -d

c. Service/unit/compose file:

services:
  caddy:
    image: caddy:latest
    container_name: caddy
    restart: unless-stopped
    ports:
      - 80:80
      - 443:443
      - 443:443/udp
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - ./caddy_config:/config
      - ./certificates:/data
    networks:
      - dapp

networks:
  dapp:
    name: dapp
    external: true

d. My complete Caddy config:

Thats config doesn’t work

{
    debug
}
test.woof.software {
    reverse_proxy http://frontend-dev:3000 {
    }
}

Thats config works!

{
    debug
}

test.woof.software {
    reverse_proxy http://172.18.0.2:3000 {
    }
}

5. Links to relevant resources:

Can we see these Caddy debug logs?

Both from the working config, and separately, from the non-working config? So we can compare results?

1 Like

Sure.
Non working config.

{
    debug
}
test.woof.software {
    reverse_proxy http://frontend-dev:3000 {
    }
}

Log when i refresh 1 time page test.woof.software/markets

{"level":"debug","ts":1724138433.4640198,"logger":"http.handlers.reverse_proxy","msg":"selected upstream","dial":"frontend-dev:3000","total_upstreams":1}
{"level":"debug","ts":1724138433.4658577,"logger":"http.handlers.reverse_proxy","msg":"upstream roundtrip","upstream":"frontend-dev:3000","duration":0.008399454,"request":{"remote_ip":"46.98.121.189","remote_port":"58290","client_ip":"46.98.121.189","proto":"HTTP/2.0","method":"GET","host":"test.woof.software","uri":"/_next/static/media/a34f9d1faa5f3315-s.p.woff2","headers":{"Sec-Fetch-Dest":["font"],"Priority":["u=1"],"X-Forwarded-For":["46.98.121.189"],"X-Forwarded-Proto":["https"],"Accept":["*/*"],"Sec-Ch-Ua-Platform":["\"Windows\""],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"],"Sec-Fetch-Mode":["cors"],"Sec-Ch-Ua":["\"Not)A;Brand\";v=\"99\", \"Google Chrome\";v=\"127\", \"Chromium\";v=\"127\""],"X-Forwarded-Host":["test.woof.software"],"Sec-Fetch-Site":["same-origin"],"Referer":["https://test.woof.software/market"],"Accept-Encoding":["gzip, deflate, br, zstd"],"Origin":["https://test.woof.software"],"Sec-Ch-Ua-Mobile":["?0"],"Accept-Language":["ru-RU,ru;q=0.9"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"test.woof.software"}},"headers":{"Accept-Ranges":["bytes"],"Last-Modified":["Tue, 13 Aug 2024 12:10:36 GMT"],"Etag":["W/\"bdac-1914ba5b260\""],"Date":["Tue, 20 Aug 2024 07:20:33 GMT"],"Keep-Alive":["timeout=5"],"Cache-Control":["public, max-age=31536000, immutable"],"Content-Type":["font/woff2"],"Content-Length":["48556"],"Connection":["keep-alive"]},"status":200}
{"level":"debug","ts":1724138433.465995,"logger":"http.handlers.reverse_proxy","msg":"upstream roundtrip","upstream":"frontend-dev:3000","duration":0.008694734,"request":{"remote_ip":"46.98.121.189","remote_port":"58290","client_ip":"46.98.121.189","proto":"HTTP/2.0","method":"GET","host":"test.woof.software","uri":"/_next/static/css/611d31c80c45315f.css","headers":{"Sec-Ch-Ua":["\"Not)A;Brand\";v=\"99\", \"Google Chrome\";v=\"127\", \"Chromium\";v=\"127\""],"Accept":["text/css,*/*;q=0.1"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"],"Sec-Fetch-Site":["same-origin"],"Sec-Fetch-Mode":["no-cors"],"Priority":["u=0"],"Accept-Encoding":["gzip, deflate, br, zstd"],"X-Forwarded-Host":["test.woof.software"],"Sec-Ch-Ua-Platform":["\"Windows\""],"Sec-Fetch-Dest":["style"],"Referer":["https://test.woof.software/market"],"Accept-Language":["ru-RU,ru;q=0.9"],"X-Forwarded-For":["46.98.121.189"],"X-Forwarded-Proto":["https"],"Sec-Ch-Ua-Mobile":["?0"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"test.woof.software"}},"headers":{"Cache-Control":["public, max-age=31536000, immutable"],"Accept-Ranges":["bytes"],"Etag":["W/\"8eb-1914ba5b260\""],"Vary":["Accept-Encoding"],"Date":["Tue, 20 Aug 2024 07:20:33 GMT"],"Connection":["keep-alive"],"Last-Modified":["Tue, 13 Aug 2024 12:10:36 GMT"],"Content-Type":["text/css; charset=UTF-8"],"Content-Encoding":["gzip"],"Keep-Alive":["timeout=5"]},"status":200}
{"level":"debug","ts":1724138433.4639525,"logger":"http.handlers.reverse_proxy","msg":"selected upstream","dial":"frontend-dev:3000","total_upstreams":1}
{"level":"debug","ts":1724138433.4752176,"logger":"http.handlers.reverse_proxy","msg":"upstream roundtrip","upstream":"frontend-dev:3000","duration":0.010430983,"request":{"remote_ip":"46.98.121.189","remote_port":"58290","client_ip":"46.98.121.189","proto":"HTTP/2.0","method":"GET","host":"test.woof.software","uri":"/_next/static/chunks/173-bb702b78f780ddcb.js","headers":{"Sec-Ch-Ua":["\"Not)A;Brand\";v=\"99\", \"Google Chrome\";v=\"127\", \"Chromium\";v=\"127\""],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"],"X-Forwarded-Host":["test.woof.software"],"Sec-Fetch-Site":["same-origin"],"Sec-Fetch-Mode":["no-cors"],"Sec-Fetch-Dest":["script"],"Sec-Ch-Ua-Platform":["\"Windows\""],"X-Forwarded-For":["46.98.121.189"],"X-Forwarded-Proto":["https"],"Accept":["*/*"],"Accept-Encoding":["gzip, deflate, br, zstd"],"Sec-Ch-Ua-Mobile":["?0"],"Referer":["https://test.woof.software/market"],"Accept-Language":["ru-RU,ru;q=0.9"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"test.woof.software"}},"headers":{"Accept-Ranges":["bytes"],"Etag":["W/\"33db-1914ba5b260\""],"Content-Type":["application/javascript; charset=UTF-8"],"Content-Encoding":["gzip"],"Cache-Control":["public, max-age=31536000, immutable"],"Last-Modified":["Tue, 13 Aug 2024 12:10:36 GMT"],"Vary":["Accept-Encoding"],"Date":["Tue, 20 Aug 2024 07:20:33 GMT"],"Connection":["keep-alive"],"Keep-Alive":["timeout=5"]},"status":200}
{"level":"debug","ts":1724138433.4788888,"logger":"http.handlers.reverse_proxy","msg":"upstream roundtrip","upstream":"frontend-dev:3000","duration":0.012590081,"request":{"remote_ip":"46.98.121.189","remote_port":"58290","client_ip":"46.98.121.189","proto":"HTTP/2.0","method":"GET","host":"test.woof.software","uri":"/_next/static/chunks/23-4496fb2f96c19021.js","headers":{"Sec-Ch-Ua-Mobile":["?0"],"Sec-Ch-Ua-Platform":["\"Windows\""],"Accept-Language":["ru-RU,ru;q=0.9"],"X-Forwarded-For":["46.98.121.189"],"Referer":["https://test.woof.software/market"],"Sec-Ch-Ua":["\"Not)A;Brand\";v=\"99\", \"Google Chrome\";v=\"127\", \"Chromium\";v=\"127\""],"Sec-Fetch-Mode":["no-cors"],"Accept-Encoding":["gzip, deflate, br, zstd"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"],"Accept":["*/*"],"Sec-Fetch-Site":["same-origin"],"Sec-Fetch-Dest":["script"],"X-Forwarded-Proto":["https"],"X-Forwarded-Host":["test.woof.software"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"test.woof.software"}},"headers":{"Cache-Control":["public, max-age=31536000, immutable"],"Vary":["Accept-Encoding"],"Content-Encoding":["gzip"],"Date":["Tue, 20 Aug 2024 07:20:33 GMT"],"Connection":["keep-alive"],"Accept-Ranges":["bytes"],"Last-Modified":["Tue, 13 Aug 2024 12:10:36 GMT"],"Etag":["W/\"1e34d-1914ba5b260\""],"Content-Type":["application/javascript; charset=UTF-8"],"Keep-Alive":["timeout=5"]},"status":200}
{"level":"debug","ts":1724138433.5198588,"logger":"http.handlers.reverse_proxy","msg":"upstream roundtrip","upstream":"frontend-dev:3000","duration":0.055169805,"request":{"remote_ip":"46.98.121.189","remote_port":"58290","client_ip":"46.98.121.189","proto":"HTTP/2.0","method":"GET","host":"test.woof.software","uri":"/_next/static/chunks/fd9d1056-ad73cf74b6ee4fd5.js","headers":{"Accept-Encoding":["gzip, deflate, br, zstd"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"],"Sec-Ch-Ua-Platform":["\"Windows\""],"Sec-Fetch-Site":["same-origin"],"Accept":["*/*"],"X-Forwarded-Host":["test.woof.software"],"X-Forwarded-For":["46.98.121.189"],"Referer":["https://test.woof.software/market"],"Sec-Ch-Ua":["\"Not)A;Brand\";v=\"99\", \"Google Chrome\";v=\"127\", \"Chromium\";v=\"127\""],"Sec-Fetch-Dest":["script"],"X-Forwarded-Proto":["https"],"Accept-Language":["ru-RU,ru;q=0.9"],"Sec-Ch-Ua-Mobile":["?0"],"Sec-Fetch-Mode":["no-cors"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"test.woof.software"}},"headers":{"Last-Modified":["Tue, 20 Aug 2024 07:14:14 GMT"],"Content-Type":["application/javascript; charset=UTF-8"],"Content-Encoding":["gzip"],"Date":["Tue, 20 Aug 2024 07:20:33 GMT"],"Connection":["keep-alive"],"Keep-Alive":["timeout=5"],"Cache-Control":["public, max-age=31536000, immutable"],"Accept-Ranges":["bytes"],"Etag":["W/\"2a321-1916ea2e170\""],"Vary":["Accept-Encoding"]},"status":200}
{"level":"debug","ts":1724138433.603898,"logger":"http.handlers.reverse_proxy","msg":"selected upstream","dial":"frontend-dev:3000","total_upstreams":1}
{"level":"debug","ts":1724138433.608114,"logger":"http.handlers.reverse_proxy","msg":"upstream roundtrip","upstream":"frontend-dev:3000","duration":0.004118291,"request":{"remote_ip":"46.98.121.189","remote_port":"58290","client_ip":"46.98.121.189","proto":"HTTP/2.0","method":"GET","host":"test.woof.software","uri":"/logo.svg","headers":{"Sec-Fetch-Mode":["no-cors"],"X-Forwarded-Proto":["https"],"Referer":["https://test.woof.software/market"],"Accept-Encoding":["gzip, deflate, br, zstd"],"X-Forwarded-Host":["test.woof.software"],"Sec-Ch-Ua-Platform":["\"Windows\""],"Accept":["image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8"],"Priority":["i"],"Sec-Ch-Ua":["\"Not)A;Brand\";v=\"99\", \"Google Chrome\";v=\"127\", \"Chromium\";v=\"127\""],"Sec-Fetch-Dest":["image"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"],"Accept-Language":["ru-RU,ru;q=0.9"],"Sec-Ch-Ua-Mobile":["?0"],"Sec-Fetch-Site":["same-origin"],"X-Forwarded-For":["46.98.121.189"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"test.woof.software"}},"headers":{"Content-Type":["image/svg+xml"],"Content-Encoding":["gzip"],"Date":["Tue, 20 Aug 2024 07:20:33 GMT"],"Connection":["keep-alive"],"Vary":["Accept-Encoding"],"Keep-Alive":["timeout=5"],"Accept-Ranges":["bytes"],"Cache-Control":["public, max-age=0"],"Last-Modified":["Tue, 13 Aug 2024 12:09:13 GMT"],"Etag":["W/\"4c3-1914ba46e28\""]},"status":200}
{"level":"debug","ts":1724138433.6246672,"logger":"http.handlers.reverse_proxy","msg":"upstream roundtrip","upstream":"frontend-dev:3000","duration":0.157339724,"request":{"remote_ip":"46.98.121.189","remote_port":"58290","client_ip":"46.98.121.189","proto":"HTTP/2.0","method":"GET","host":"test.woof.software","uri":"/_next/static/chunks/223-a30e8e8291bed0da.js","headers":{"Sec-Ch-Ua":["\"Not)A;Brand\";v=\"99\", \"Google Chrome\";v=\"127\", \"Chromium\";v=\"127\""],"Referer":["https://test.woof.software/market"],"Sec-Ch-Ua-Mobile":["?0"],"Accept-Language":["ru-RU,ru;q=0.9"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"],"Sec-Fetch-Site":["same-origin"],"Sec-Fetch-Dest":["script"],"Accept-Encoding":["gzip, deflate, br, zstd"],"X-Forwarded-Proto":["https"],"X-Forwarded-Host":["test.woof.software"],"Sec-Ch-Ua-Platform":["\"Windows\""],"Accept":["*/*"],"Sec-Fetch-Mode":["no-cors"],"X-Forwarded-For":["46.98.121.189"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"test.woof.software"}},"headers":{"Vary":["RSC, Next-Router-State-Tree, Next-Router-Prefetch, Accept-Encoding"],"X-Powered-By":["Next.js"],"Content-Encoding":["gzip"],"Connection":["keep-alive"],"Cache-Control":["no-cache, no-store, max-age=0, must-revalidate"],"Content-Type":["text/html; charset=utf-8"],"Date":["Tue, 20 Aug 2024 07:20:33 GMT"],"Keep-Alive":["timeout=5"],"Link":["</_next/static/media/a34f9d1faa5f3315-s.p.woff2>; rel=preload; as=\"font\"; crossorigin=\"\"; type=\"font/woff2\""]},"status":404}
{"level":"debug","ts":1724138433.6261277,"logger":"http.handlers.reverse_proxy","msg":"upstream roundtrip","upstream":"frontend-dev:3000","duration":0.159264425,"request":{"remote_ip":"46.98.121.189","remote_port":"58290","client_ip":"46.98.121.189","proto":"HTTP/2.0","method":"GET","host":"test.woof.software","uri":"/_next/static/chunks/app/page-c6795d19011e6d67.js","headers":{"Sec-Ch-Ua":["\"Not)A;Brand\";v=\"99\", \"Google Chrome\";v=\"127\", \"Chromium\";v=\"127\""],"X-Forwarded-For":["46.98.121.189"],"Sec-Ch-Ua-Mobile":["?0"],"X-Forwarded-Proto":["https"],"X-Forwarded-Host":["test.woof.software"],"Accept":["*/*"],"Referer":["https://test.woof.software/market"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"],"Sec-Ch-Ua-Platform":["\"Windows\""],"Accept-Encoding":["gzip, deflate, br, zstd"],"Accept-Language":["ru-RU,ru;q=0.9"],"Sec-Fetch-Site":["same-origin"],"Sec-Fetch-Mode":["no-cors"],"Sec-Fetch-Dest":["script"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"test.woof.software"}},"headers":{"Cache-Control":["no-cache, no-store, max-age=0, must-revalidate"],"Date":["Tue, 20 Aug 2024 07:20:33 GMT"],"Keep-Alive":["timeout=5"],"Vary":["RSC, Next-Router-State-Tree, Next-Router-Prefetch, Accept-Encoding"],"Link":["</_next/static/media/a34f9d1faa5f3315-s.p.woff2>; rel=preload; as=\"font\"; crossorigin=\"\"; type=\"font/woff2\""],"X-Powered-By":["Next.js"],"Content-Type":["text/html; charset=utf-8"],"Content-Encoding":["gzip"],"Connection":["keep-alive"]},"status":404}
{"level":"debug","ts":1724138433.6414387,"logger":"http.handlers.reverse_proxy","msg":"upstream roundtrip","upstream":"frontend-dev:3000","duration":0.176070748,"request":{"remote_ip":"46.98.121.189","remote_port":"58290","client_ip":"46.98.121.189","proto":"HTTP/2.0","method":"GET","host":"test.woof.software","uri":"/_next/static/chunks/main-app-f9a1d4e8e65f8b84.js","headers":{"X-Forwarded-Proto":["https"],"Sec-Ch-Ua-Mobile":["?0"],"Accept":["*/*"],"Sec-Fetch-Mode":["no-cors"],"Accept-Encoding":["gzip, deflate, br, zstd"],"Sec-Ch-Ua-Platform":["\"Windows\""],"Referer":["https://test.woof.software/market"],"X-Forwarded-For":["46.98.121.189"],"Sec-Fetch-Dest":["script"],"Accept-Language":["ru-RU,ru;q=0.9"],"Sec-Fetch-Site":["same-origin"],"Sec-Ch-Ua":["\"Not)A;Brand\";v=\"99\", \"Google Chrome\";v=\"127\", \"Chromium\";v=\"127\""],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"],"X-Forwarded-Host":["test.woof.software"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"test.woof.software"}},"headers":{"Date":["Tue, 20 Aug 2024 07:20:33 GMT"],"Connection":["keep-alive"],"Etag":["W/\"1d7-1916ea2e170\""],"Content-Length":["471"],"Last-Modified":["Tue, 20 Aug 2024 07:14:14 GMT"],"Content-Type":["application/javascript; charset=UTF-8"],"Vary":["Accept-Encoding"],"Keep-Alive":["timeout=5"],"Cache-Control":["public, max-age=31536000, immutable"],"Accept-Ranges":["bytes"]},"status":200}
{"level":"debug","ts":1724138433.644484,"logger":"http.handlers.reverse_proxy","msg":"upstream roundtrip","upstream":"frontend-dev:3000","duration":0.178439565,"request":{"remote_ip":"46.98.121.189","remote_port":"58290","client_ip":"46.98.121.189","proto":"HTTP/2.0","method":"GET","host":"test.woof.software","uri":"/_next/static/chunks/app/layout-55d22292adf0eefc.js","headers":{"Sec-Fetch-Site":["same-origin"],"Sec-Ch-Ua":["\"Not)A;Brand\";v=\"99\", \"Google Chrome\";v=\"127\", \"Chromium\";v=\"127\""],"Sec-Ch-Ua-Mobile":["?0"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"],"Sec-Ch-Ua-Platform":["\"Windows\""],"Referer":["https://test.woof.software/market"],"X-Forwarded-Proto":["https"],"Accept-Language":["ru-RU,ru;q=0.9"],"Accept":["*/*"],"X-Forwarded-Host":["test.woof.software"],"Accept-Encoding":["gzip, deflate, br, zstd"],"Sec-Fetch-Mode":["no-cors"],"Sec-Fetch-Dest":["script"],"X-Forwarded-For":["46.98.121.189"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"test.woof.software"}},"headers":{"Vary":["RSC, Next-Router-State-Tree, Next-Router-Prefetch, Accept-Encoding"],"Content-Type":["text/html; charset=utf-8"],"Content-Encoding":["gzip"],"Date":["Tue, 20 Aug 2024 07:20:33 GMT"],"Connection":["keep-alive"],"Keep-Alive":["timeout=5"],"Cache-Control":["no-cache, no-store, max-age=0, must-revalidate"],"Link":["</_next/static/media/a34f9d1faa5f3315-s.p.woff2>; rel=preload; as=\"font\"; crossorigin=\"\"; type=\"font/woff2\""],"X-Powered-By":["Next.js"]},"status":404}
{"level":"debug","ts":1724138433.714718,"logger":"http.handlers.reverse_proxy","msg":"selected upstream","dial":"frontend-dev:3000","total_upstreams":1}
{"level":"debug","ts":1724138433.717198,"logger":"http.handlers.reverse_proxy","msg":"upstream roundtrip","upstream":"frontend-dev:3000","duration":0.002416868,"request":{"remote_ip":"46.98.121.189","remote_port":"58290","client_ip":"46.98.121.189","proto":"HTTP/2.0","method":"GET","host":"test.woof.software","uri":"/favicon.ico","headers":{"Sec-Ch-Ua-Mobile":["?0"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"],"Accept-Encoding":["gzip, deflate, br, zstd"],"Sec-Ch-Ua-Platform":["\"Windows\""],"Sec-Fetch-Site":["same-origin"],"X-Forwarded-Proto":["https"],"Referer":["https://test.woof.software/market"],"Sec-Fetch-Mode":["no-cors"],"Sec-Fetch-Dest":["image"],"Sec-Ch-Ua":["\"Not)A;Brand\";v=\"99\", \"Google Chrome\";v=\"127\", \"Chromium\";v=\"127\""],"Accept":["image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8"],"Accept-Language":["ru-RU,ru;q=0.9"],"Priority":["u=1, i"],"X-Forwarded-For":["46.98.121.189"],"X-Forwarded-Host":["test.woof.software"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"test.woof.software"}},"headers":{"Keep-Alive":["timeout=5"],"Accept-Ranges":["bytes"],"Vary":["Accept-Encoding"],"Etag":["W/\"3c2e-1916ea17df8\""],"Content-Type":["image/x-icon"],"Content-Encoding":["gzip"],"Date":["Tue, 20 Aug 2024 07:20:33 GMT"],"Connection":["keep-alive"],"Cache-Control":["public, max-age=0"],"Last-Modified":["Tue, 20 Aug 2024 07:12:43 GMT"]},"status":200}

Working config.

{
    debug
}
test.woof.software {
    reverse_proxy http://172.18.0.2:3000 {
    }
}

Logs

{"level":"debug","ts":1724138293.4821827,"logger":"http.handlers.reverse_proxy","msg":"selected upstream","dial":"172.18.0.2:3000","total_upstreams":1}
{"level":"debug","ts":1724138293.4822602,"logger":"http.handlers.reverse_proxy","msg":"selected upstream","dial":"172.18.0.2:3000","total_upstreams":1}
{"level":"debug","ts":1724138293.4821827,"logger":"http.handlers.reverse_proxy","msg":"selected upstream","dial":"172.18.0.2:3000","total_upstreams":1}
{"level":"debug","ts":1724138293.4883015,"logger":"http.handlers.reverse_proxy","msg":"upstream roundtrip","upstream":"172.18.0.2:3000","duration":0.005987998,"request":{"remote_ip":"46.98.121.189","remote_port":"58140","client_ip":"46.98.121.189","proto":"HTTP/2.0","method":"GET","host":"test.woof.software","uri":"/_next/static/chunks/80.0ad6393b4dc32fc0.js","headers":{"Sec-Ch-Ua-Mobile":["?0"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"],"Sec-Fetch-Site":["same-origin"],"Sec-Fetch-Mode":["no-cors"],"Cache-Control":["no-cache"],"X-Forwarded-For":["46.98.121.189"],"Pragma":["no-cache"],"X-Forwarded-Proto":["https"],"X-Forwarded-Host":["test.woof.software"],"Accept-Language":["ru-RU,ru;q=0.9"],"Accept":["*/*"],"Referer":["https://test.woof.software/market"],"Accept-Encoding":["gzip, deflate, br, zstd"],"Sec-Ch-Ua":["\"Not)A;Brand\";v=\"99\", \"Google Chrome\";v=\"127\", \"Chromium\";v=\"127\""],"Sec-Ch-Ua-Platform":["\"Windows\""],"Sec-Fetch-Dest":["script"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"test.woof.software"}},"headers":{"Cache-Control":["public, max-age=31536000, immutable"],"Etag":["W/\"18b46-1916ea2e170\""],"Content-Encoding":["gzip"],"Keep-Alive":["timeout=5"],"Accept-Ranges":["bytes"],"Last-Modified":["Tue, 20 Aug 2024 07:14:14 GMT"],"Content-Type":["application/javascript; charset=UTF-8"],"Vary":["Accept-Encoding"],"Date":["Tue, 20 Aug 2024 07:18:13 GMT"],"Connection":["keep-alive"]},"status":200}
{"level":"debug","ts":1724138293.4898422,"logger":"http.handlers.reverse_proxy","msg":"upstream roundtrip","upstream":"172.18.0.2:3000","duration":0.007596119,"request":{"remote_ip":"46.98.121.189","remote_port":"58140","client_ip":"46.98.121.189","proto":"HTTP/2.0","method":"GET","host":"test.woof.software","uri":"/_next/static/chunks/866.707a8bc92870c7c0.js","headers":{"Accept-Encoding":["gzip, deflate, br, zstd"],"Pragma":["no-cache"],"Sec-Ch-Ua":["\"Not)A;Brand\";v=\"99\", \"Google Chrome\";v=\"127\", \"Chromium\";v=\"127\""],"Accept":["*/*"],"Sec-Fetch-Mode":["no-cors"],"Sec-Ch-Ua-Mobile":["?0"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"],"X-Forwarded-Host":["test.woof.software"],"Sec-Fetch-Dest":["script"],"Cache-Control":["no-cache"],"Accept-Language":["ru-RU,ru;q=0.9"],"X-Forwarded-For":["46.98.121.189"],"X-Forwarded-Proto":["https"],"Sec-Ch-Ua-Platform":["\"Windows\""],"Sec-Fetch-Site":["same-origin"],"Referer":["https://test.woof.software/market"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"test.woof.software"}},"headers":{"Vary":["Accept-Encoding"],"Date":["Tue, 20 Aug 2024 07:18:13 GMT"],"Keep-Alive":["timeout=5"],"Cache-Control":["public, max-age=31536000, immutable"],"Accept-Ranges":["bytes"],"Last-Modified":["Tue, 20 Aug 2024 07:14:14 GMT"],"Etag":["W/\"21952-1916ea2e170\""],"Content-Type":["application/javascript; charset=UTF-8"],"Content-Encoding":["gzip"],"Connection":["keep-alive"]},"status":200}
{"level":"debug","ts":1724138293.495786,"logger":"http.handlers.reverse_proxy","msg":"upstream roundtrip","upstream":"172.18.0.2:3000","duration":0.013426666,"request":{"remote_ip":"46.98.121.189","remote_port":"58140","client_ip":"46.98.121.189","proto":"HTTP/2.0","method":"GET","host":"test.woof.software","uri":"/_next/static/chunks/266.2b1d926e013d88b5.js","headers":{"Referer":["https://test.woof.software/market"],"Accept":["*/*"],"Sec-Fetch-Site":["same-origin"],"X-Forwarded-Host":["test.woof.software"],"X-Forwarded-For":["46.98.121.189"],"Sec-Ch-Ua-Mobile":["?0"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"],"Sec-Fetch-Mode":["no-cors"],"Pragma":["no-cache"],"Sec-Ch-Ua-Platform":["\"Windows\""],"Sec-Fetch-Dest":["script"],"Accept-Language":["ru-RU,ru;q=0.9"],"Cache-Control":["no-cache"],"Sec-Ch-Ua":["\"Not)A;Brand\";v=\"99\", \"Google Chrome\";v=\"127\", \"Chromium\";v=\"127\""],"Accept-Encoding":["gzip, deflate, br, zstd"],"X-Forwarded-Proto":["https"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"test.woof.software"}},"headers":{"Cache-Control":["public, max-age=31536000, immutable"],"Content-Encoding":["gzip"],"Date":["Tue, 20 Aug 2024 07:18:13 GMT"],"Accept-Ranges":["bytes"],"Last-Modified":["Tue, 20 Aug 2024 07:14:14 GMT"],"Etag":["W/\"12323-1916ea2e170\""],"Content-Type":["application/javascript; charset=UTF-8"],"Vary":["Accept-Encoding"],"Connection":["keep-alive"],"Keep-Alive":["timeout=5"]},"status":200}
{"level":"debug","ts":1724138293.5836427,"logger":"http.handlers.reverse_proxy","msg":"selected upstream","dial":"172.18.0.2:3000","total_upstreams":1}
{"level":"debug","ts":1724138293.5902674,"logger":"http.handlers.reverse_proxy","msg":"upstream roundtrip","upstream":"172.18.0.2:3000","duration":0.006555357,"request":{"remote_ip":"46.98.121.189","remote_port":"58140","client_ip":"46.98.121.189","proto":"HTTP/2.0","method":"GET","host":"test.woof.software","uri":"/_next/static/chunks/726.b999cdd41961b266.js","headers":{"Accept":["*/*"],"Sec-Fetch-Site":["same-origin"],"Cache-Control":["no-cache"],"Sec-Ch-Ua-Platform":["\"Windows\""],"Pragma":["no-cache"],"Sec-Ch-Ua":["\"Not)A;Brand\";v=\"99\", \"Google Chrome\";v=\"127\", \"Chromium\";v=\"127\""],"Sec-Fetch-Dest":["script"],"Accept-Language":["ru-RU,ru;q=0.9"],"X-Forwarded-For":["46.98.121.189"],"Sec-Fetch-Mode":["no-cors"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"],"X-Forwarded-Host":["test.woof.software"],"Accept-Encoding":["gzip, deflate, br, zstd"],"Sec-Ch-Ua-Mobile":["?0"],"Referer":["https://test.woof.software/market"],"X-Forwarded-Proto":["https"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"test.woof.software"}},"headers":{"Connection":["keep-alive"],"Keep-Alive":["timeout=5"],"Accept-Ranges":["bytes"],"Etag":["W/\"68-1916ea2e170\""],"Content-Type":["application/javascript; charset=UTF-8"],"Vary":["Accept-Encoding"],"Date":["Tue, 20 Aug 2024 07:18:13 GMT"],"Cache-Control":["public, max-age=31536000, immutable"],"Last-Modified":["Tue, 20 Aug 2024 07:14:14 GMT"],"Content-Length":["104"]},"status":200}
{"level":"debug","ts":1724138294.1403248,"logger":"http.handlers.reverse_proxy","msg":"selected upstream","dial":"172.18.0.2:3000","total_upstreams":1}
{"level":"debug","ts":1724138294.1403248,"logger":"http.handlers.reverse_proxy","msg":"selected upstream","dial":"172.18.0.2:3000","total_upstreams":1}
{"level":"debug","ts":1724138294.144262,"logger":"http.handlers.reverse_proxy","msg":"upstream roundtrip","upstream":"172.18.0.2:3000","duration":0.003860421,"request":{"remote_ip":"46.98.121.189","remote_port":"58140","client_ip":"46.98.121.189","proto":"HTTP/2.0","method":"GET","host":"test.woof.software","uri":"/usdc.svg","headers":{"Pragma":["no-cache"],"Sec-Fetch-Site":["same-origin"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"],"X-Forwarded-For":["46.98.121.189"],"Sec-Fetch-Dest":["image"],"Accept-Language":["ru-RU,ru;q=0.9"],"Referer":["https://test.woof.software/market"],"Priority":["i"],"Accept":["image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8"],"Sec-Fetch-Mode":["no-cors"],"Cache-Control":["no-cache"],"Sec-Ch-Ua":["\"Not)A;Brand\";v=\"99\", \"Google Chrome\";v=\"127\", \"Chromium\";v=\"127\""],"Accept-Encoding":["gzip, deflate, br, zstd"],"Sec-Ch-Ua-Mobile":["?0"],"Sec-Ch-Ua-Platform":["\"Windows\""],"X-Forwarded-Proto":["https"],"X-Forwarded-Host":["test.woof.software"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"test.woof.software"}},"headers":{"Cache-Control":["public, max-age=0"],"Last-Modified":["Tue, 20 Aug 2024 07:12:43 GMT"],"Etag":["W/\"9a1-1916ea17df8\""],"Content-Type":["image/svg+xml"],"Content-Encoding":["gzip"],"Connection":["keep-alive"],"Accept-Ranges":["bytes"],"Vary":["Accept-Encoding"],"Date":["Tue, 20 Aug 2024 07:18:14 GMT"],"Keep-Alive":["timeout=5"]},"status":200}
{"level":"debug","ts":1724138294.146081,"logger":"http.handlers.reverse_proxy","msg":"selected upstream","dial":"172.18.0.2:3000","total_upstreams":1}
{"level":"debug","ts":1724138294.146308,"logger":"http.handlers.reverse_proxy","msg":"upstream roundtrip","upstream":"172.18.0.2:3000","duration":0.003629793,"request":{"remote_ip":"46.98.121.189","remote_port":"58140","client_ip":"46.98.121.189","proto":"HTTP/2.0","method":"GET","host":"test.woof.software","uri":"/eth.svg","headers":{"Priority":["i"],"Sec-Ch-Ua":["\"Not)A;Brand\";v=\"99\", \"Google Chrome\";v=\"127\", \"Chromium\";v=\"127\""],"Sec-Ch-Ua-Mobile":["?0"],"Accept-Encoding":["gzip, deflate, br, zstd"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"],"Sec-Fetch-Dest":["image"],"Referer":["https://test.woof.software/market"],"X-Forwarded-For":["46.98.121.189"],"Accept-Language":["ru-RU,ru;q=0.9"],"Pragma":["no-cache"],"Sec-Fetch-Mode":["no-cors"],"Sec-Ch-Ua-Platform":["\"Windows\""],"Sec-Fetch-Site":["same-origin"],"Cache-Control":["no-cache"],"X-Forwarded-Proto":["https"],"X-Forwarded-Host":["test.woof.software"],"Accept":["image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"test.woof.software"}},"headers":{"Keep-Alive":["timeout=5"],"Last-Modified":["Tue, 20 Aug 2024 07:12:43 GMT"],"Content-Type":["image/svg+xml"],"Content-Encoding":["gzip"],"Vary":["Accept-Encoding"],"Date":["Tue, 20 Aug 2024 07:18:14 GMT"],"Connection":["keep-alive"],"Accept-Ranges":["bytes"],"Cache-Control":["public, max-age=0"],"Etag":["W/\"4e3-1916ea17df8\""]},"status":200}
{"level":"debug","ts":1724138294.1547072,"logger":"http.handlers.reverse_proxy","msg":"upstream roundtrip","upstream":"172.18.0.2:3000","duration":0.00856125,"request":{"remote_ip":"46.98.121.189","remote_port":"58140","client_ip":"46.98.121.189","proto":"HTTP/2.0","method":"GET","host":"test.woof.software","uri":"/tether.svg","headers":{"Accept-Encoding":["gzip, deflate, br, zstd"],"Sec-Ch-Ua":["\"Not)A;Brand\";v=\"99\", \"Google Chrome\";v=\"127\", \"Chromium\";v=\"127\""],"Sec-Fetch-Site":["same-origin"],"Sec-Ch-Ua-Platform":["\"Windows\""],"Referer":["https://test.woof.software/market"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"],"Priority":["i"],"X-Forwarded-Proto":["https"],"X-Forwarded-Host":["test.woof.software"],"Sec-Fetch-Dest":["image"],"Accept-Language":["ru-RU,ru;q=0.9"],"Accept":["image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8"],"Sec-Fetch-Mode":["no-cors"],"Pragma":["no-cache"],"X-Forwarded-For":["46.98.121.189"],"Cache-Control":["no-cache"],"Sec-Ch-Ua-Mobile":["?0"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"test.woof.software"}},"headers":{"Cache-Control":["public, max-age=0"],"Etag":["W/\"5b7-1916ea17df8\""],"Content-Type":["image/svg+xml"],"Content-Encoding":["gzip"],"Date":["Tue, 20 Aug 2024 07:18:14 GMT"],"Connection":["keep-alive"],"Keep-Alive":["timeout=5"],"Accept-Ranges":["bytes"],"Vary":["Accept-Encoding"],"Last-Modified":["Tue, 20 Aug 2024 07:12:43 GMT"]},"status":200}
{"level":"debug","ts":1724138294.1907241,"logger":"http.handlers.reverse_proxy","msg":"selected upstream","dial":"172.18.0.2:3000","total_upstreams":1}
{"level":"debug","ts":1724138294.1923013,"logger":"http.handlers.reverse_proxy","msg":"upstream roundtrip","upstream":"172.18.0.2:3000","duration":0.001513292,"request":{"remote_ip":"46.98.121.189","remote_port":"58140","client_ip":"46.98.121.189","proto":"HTTP/2.0","method":"GET","host":"test.woof.software","uri":"/ether.svg","headers":{"X-Forwarded-Proto":["https"],"X-Forwarded-Host":["test.woof.software"],"Sec-Fetch-Site":["same-origin"],"Priority":["i"],"Sec-Ch-Ua":["\"Not)A;Brand\";v=\"99\", \"Google Chrome\";v=\"127\", \"Chromium\";v=\"127\""],"Sec-Ch-Ua-Platform":["\"Windows\""],"Cache-Control":["no-cache"],"Accept":["image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8"],"Accept-Language":["ru-RU,ru;q=0.9"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"],"Accept-Encoding":["gzip, deflate, br, zstd"],"Referer":["https://test.woof.software/market"],"Sec-Ch-Ua-Mobile":["?0"],"Sec-Fetch-Mode":["no-cors"],"X-Forwarded-For":["46.98.121.189"],"Pragma":["no-cache"],"Sec-Fetch-Dest":["image"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"test.woof.software"}},"headers":{"Keep-Alive":["timeout=5"],"Cache-Control":["public, max-age=0"],"Last-Modified":["Tue, 20 Aug 2024 07:12:43 GMT"],"Etag":["W/\"3ea-1916ea17df8\""],"Content-Type":["image/svg+xml"],"Content-Length":["1002"],"Date":["Tue, 20 Aug 2024 07:18:14 GMT"],"Connection":["keep-alive"],"Accept-Ranges":["bytes"],"Vary":["Accept-Encoding"]},"status":200}

docker network inspect dapp (my network) it show what containers in same network

docker network inspect dapp
[
    {
        "Name": "dapp",
        "Id": "3ad67c7f3488abbd5b4d18fc58aa98e38b6cfe233566ee2344724893636b79c1",
        "Created": "2024-08-13T09:55:28.254239946Z",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": {},
            "Config": [
                {
                    "Subnet": "172.18.0.0/16",
                    "Gateway": "172.18.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "7cd55d3e5523fabbeed8cd790188bb9fcb3bf4dd860c7bfb69d38de5b032d149": {
                "Name": "frontend-dev",
                "EndpointID": "e79b1d018b76629c21c373baab122190720ac7072ccf610d5818038364849873",
                "MacAddress": "02:42:ac:12:00:02",
                "IPv4Address": "172.18.0.2/16",
                "IPv6Address": ""
            },
            "a6f51da3841603ed9fadff670022fb92179524401774c4d987ce38abfa3b2b1b": {
                "Name": "frontend-stage",
                "EndpointID": "010bee83a8a58ad7e048bbe2f4dc5df51bcecd57371f5c8a7acc91fc0b086eb0",
                "MacAddress": "02:42:ac:12:00:04",
                "IPv4Address": "172.18.0.4/16",
                "IPv6Address": ""
            },
            "d9b6a7dc1750eb197b7c768ef1870f3fdc611c1131ceb71ec2c490fec9b588f0": {
                "Name": "caddy",
                "EndpointID": "6e277cff7d6409ce013c7ac151456797e7ca37c47f91d42b42a4e3fab9bebf44",
                "MacAddress": "02:42:ac:12:00:03",
                "IPv4Address": "172.18.0.3/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {}
    }
]

So, the first thing I’m noticing is that they seem to have different request patterns for some reason?

The three 404s in the non-working logs I can see are for the URIs:

  • /_next/static/chunks/223-a30e8e8291bed0da.js
  • /_next/static/chunks/main-app-f9a1d4e8e65f8b84.js
  • /_next/static/chunks/app/layout-55d22292adf0eefc.js

But I can’t really see equivalents in the “working” config logs. There’s no app/layout-[abc123].js, no main-app-[abc123].js and no [123]-[abc123].js URIs in the request list when it’s “working”.

The working configs all have /_next/static/chunks/[123].[abc123].js formatted requests and they all work. The working config also has a bunch of direct .svg requests. It’s like they don’t seem equivalent at all.

One other thing I notice is that every single 404 in the logs has the header X-Powered-By: Next.js. I can’t see this response header in any of the working requests.

The more I look at it the more I wonder if frontend-dev actually resolves to 172.18.0.2 or if there’s some kind of Docker networking issue directing traffic to a different version of the app, or something.

I can’t find anywhere that Caddy isn’t functioning as you’ve configured it, faithfully proxying requests upstream and returning the upstream response to the client. Obviously the upstream is differentiating the requests somehow - although it’s not clear to me exactly how, maybe it’s clearer to someone else - but I’m not sure what the upstream requires with respect to your Caddy configuration, I’m afraid.

1 Like

It’s strange behavior i tried to test 2 days((( but i can’t find solution. I try it on local machine without SSL, and it works well with same config for proxy_pass.
I leave it and use nginx now for that project. And i try caddy on another project. Thanks for answer!

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