Reverse proxy response with empty

1. The problem I’m having:

I am trying to expose a http server to my friend by reverse proxying:

   Server      <->     My PC     <->   My friend
192.168.2.116        10.xx.xx.1        10.xx.xx.2

After running caddy rerverse-proxy on my PC, the reverse proxyed address respond empty.

2. Error messages and/or full log output:

2023/06/21 14:37:18.609 WARN    admin   admin endpoint disabled
2023/06/21 14:37:18.609 INFO    tls.cache.maintenance   started background certificate maintenance      {"cache": "0xc000025ab0"}
2023/06/21 14:37:18.609 WARN    http    automatic HTTPS is completely disabled for server       {"server_name": "proxy"}
2023/06/21 14:37:18.610 INFO    tls     cleaning storage unit   {"description": "FileStorage:C:\\Users\\sheey\\AppData\\Roaming\\Caddy"}
2023/06/21 14:37:18.611 INFO    http.log        server running  {"name": "proxy", "protocols": ["h1", "h2", "h3"]}
Caddy proxying http://0.0.0.0:1234 -> 192.168.2.116:80
2023/06/21 14:37:18.612 INFO    tls     finished cleaning storage units

3. Caddy version:

v2.6.4 h1:2hwYqiRwk1tf3VruhMpLcYTg+11fCdr8S3jhNAdnPy8=

4. How I installed and ran Caddy:

scoop install caddy

a. System environment:

Windows 11, x86_64.

b. Command:

caddy reverse-proxy --from http://0.0.0.0:1234 --to http://192.168.2.116 --debug

The server (which also behind caddy):

$ curl -v http://192.168.2.116
*   Trying 192.168.2.116:80...
* Connected to 192.168.2.116 (192.168.2.116) port 80 (#0)
> GET / HTTP/1.1
> Host: 192.168.2.116
> User-Agent: curl/8.0.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: text/html; charset=utf-8
< Date: Wed, 21 Jun 2023 14:49:12 GMT
< Etag: "ggf25z5fp79j0"
< Server: Caddy
< Vary: Accept-Encoding
< X-Powered-By: Next.js
< Transfer-Encoding: chunked
<
<!DOCTYPE html><html l... (html body)

caddy proxying:

$ curl -v http://localhost:1234
*   Trying 127.0.0.1:1234...
* Connected to localhost (127.0.0.1) port 1234 (#0)
> GET / HTTP/1.1
> Host: localhost:1234
> User-Agent: curl/8.0.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: Caddy
< Date: Wed, 21 Jun 2023 14:50:09 GMT
< Content-Length: 0
<
* Connection #0 to host localhost left intact

The --from flag in your command specifies a Host of 0.0.0.0. Your subsequent request uses localhost, which doesn’t match, so Caddy has nothing to do, so it gives an empty response.

If you do --from :1234 it should work.

1 Like

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