Listening on a specific IP and proxying requests

Hi,

I’m trying to force Caddy to listen on a specific IP (59.161.27.119) and forward requests to another IP (59.161.27.120 …which actually serves the sites) by generating Let’s Encrypt certificates for them.

My Caddyfile is like:
59.161.27.119:80
my.website.com {
proxy / 59.161.27.120:80
}

and I get a Parse error: Unknown directive ‘my.website.com.

I’m clearly making a logical error, yet, I couldn’t find out how to implement that.

Thanks very much in advance for any help.

Caddy is trying to process my.website.com as a directive for 59.161.27.119:80. My hunch is that this is because the first line in the Caddyfile is a site address (good) but doesn’t open a directive block (making Caddy think the rest of the file is flat and contains only directives for the site).

Try something like:

59.161.27.119:80 {
}
my.website.com {
    proxy / 59.161.27.120:80
}

See the Caddyfile documentation, where it specifies expected syntax for Caddyfiles with multiple vhosts.

Thanks so much. That worked.

I also tried using with bind command and that worked too. Appreciate.

1 Like

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