Reverse Proxy with local DNS

1. The problem I’m having:

Hi, guys,
I’m trying to do a reverse proxy with a subdomain that is not registered (however I have registered in my /etc/hosts).
I’m am not sure what should I do to make this works since the subdomain does not exist.

I want to go to waiw.brun0-pi and reverse to brun0-pi:8080

2. Error messages and/or full log output:

2023/08/22 16:38:02 gokrazy: attempt 25, starting [“/user/caddy” “run” “–config” “/etc/caddy/Caddyfile”]
{“level”:“info”,“ts”:1692718682.9332054,“msg”:“using provided configuration”,“config_file”:“/etc/caddy/Caddyfile”,“config_adapter”:“”}
{“level”:“warn”,“ts”:1692718682.935579,“msg”:“Caddyfile input is not formatted; run ‘caddy fmt --overwrite’ to fix inconsistencies”,“adapter”:“caddyfile”,“file”:“/etc/caddy/Caddyfile”,“line”:2}
{“level”:“info”,“ts”:1692718682.9371598,“logger”:“admin”,“msg”:“admin endpoint started”,“address”:“localhost:2019”,“enforce_origin”:false,“origins”:[“//[::1]:2019”,“//”,“//localhost:2019”]}
{“level”:“warn”,“ts”:1692718682.9375193,“logger”:“http.auto_https”,“msg”:“server is listening only on the HTTP port, so no automatic HTTPS will be applied to this server”,“server_name”:“srv0”,“http_port”:80}
{“level”:“info”,“ts”:1692718682.9375575,“logger”:“tls.cache.maintenance”,“msg”:“started background certificate maintenance”,“cache”:“0x4000578000”}
{“level”:“info”,“ts”:1692718682.9381347,“logger”:“tls”,“msg”:“cleaning storage unit”,“description”:“FileStorage:/perm/home/caddy/.local/share/caddy”}
{“level”:“info”,“ts”:1692718682.9382157,“logger”:“tls”,“msg”:“finished cleaning storage units”}
{“level”:“info”,“ts”:1692718682.9382358,“logger”:“tls.cache.maintenance”,“msg”:“stopped background certificate maintenance”,“cache”:“0x4000578000”}
Error: loading initial config: loading new config: http app module: start: listening on :80: listen tcp :80: bind: address already in use

3. Caddy version:

Latest (2.7.4)

4. How I installed and ran Caddy:

Using on gokrazy (Caddy HTTP server :: gokrazy)

a. System environment:

Gokrazy raspberry pi 4b

d. My complete Caddy config:

http://waiw.localhost {
      reverse_proxy localhost:8080

Note that caddy is running on a raspberry pi ( - brun0-pi)

I know that the error message is saying port 80 is already in use so I wanted to ask 2 things

  • How can I start caddy on a different port
  • Is the Caddyfile correct to access the waiw.brun0-pi in browser and redirect to localhost:8080 ?

Specify the port in your site address:

But what else is using port 80 on your device? You’ll have a better time if you let Caddy use the default port(s). You can change whatever is currently using port 80 to use some other port, then have Caddy proxy to that port, matching by hostname.

It’s not a redirect, it’s a proxy. Very different things. A redirect is a special kind of HTTP response telling the client “please try again at this other URL”.

But no, waiw.brun0-pi is not waiw.localhost so Caddy will not have a match that hostname. You didn’t configure it to do anything with waiw.brun0-pi.

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