Help Wanted for Reverse proxying

1. Output of caddy version:

v2.6.2 h1:wKoFIxpmOJLGl3QXoo6PNbYvGW4xLEgo32GPBEjWL8o=

2. How I run Caddy:

Installed from official repo

a. System environment:

Ubuntu 20.04 LTS

b. Command:

systemctl start caddy

c. Service/unit/compose file:

Paste full file contents here.
caddy.service - Caddy
     Loaded: loaded (/lib/systemd/system/caddy.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2023-01-18 22:10:56 UTC; 11min ago
       Docs: https://caddyserver.com/docs/
   Main PID: 19290 (caddy)
      Tasks: 7 (limit: 1066)
     Memory: 8.1M
     CGroup: /system.slice/caddy.service
             └─19290 /usr/bin/caddy run --environ --config /etc/caddy/Caddyfile

d. My complete Caddy config:

my.domain
{
    tls admin@my.domain
    encode gzip
    root * /var/www/html/
    file_server
    log {
        output file /var/log/caddy/access.log
    }
    handle /path {
        reverse_proxy 127.0.0.1:10020
    }
}

3. The problem I’m having:

Caddy spits Error when I reload it.

4. Error messages and/or full log output:

WARN    Caddyfile input is not formatted; run the 'caddy fmt' command to fix inconsistencies    {"adapter": "caddyfile", "file": "Caddyfile", "line": 1}

5. What I already tried:

Already tried caddy fmt and replaced the output but its returning this error

WARN    Caddyfile input is not formatted; run the 'caddy fmt' command to fix inconsistencies    {"adapter": "caddyfile", "file": "Caddyfile", "line": 2}

6. Links to relevant resources:

Hi there, I think you missed filling out the second half of the help template, so we don’t really have any way to help you.

Hi,
I updated it

Can you help me now?

That’s not an error, that’s just a warning, as indicated by the WARN at the front of that log line.

It’s just a suggestion/reminder that you should format your config with caddy fmt to clean up indentation.

In particular, you shouldn’t put the { brace for your site address on the next line, it should be on the same line, similarly to your other directives.

Path matching in Caddy is exact, so /path only matches exactly /path and not /path/foo. Use /path* instead if you want to match more.

Also, you probably should wrap your static site directives in another handle to make sure they’re mutually exclusive:

my.domain {
	tls admin@my.domain
	encode gzip

	handle /path* {
		reverse_proxy 127.0.0.1:10020
	}

	handle {
		root * /var/www/html
		file_server
	}
}

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