Caddy on device with multiple IP address

1. Caddy version (caddy version):

v2.4.6

2. How I run Caddy:

loaded as a service. autostarts.

a. System environment:

Distributor ID: Debian
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
Codename:       bullseye

b. Command:

Paste command here.

c. Service/unit/compose file:

Not using docker

Caddy is running nicely here and everything is working. However, the device it runs on currently has 1 ethernet nic with one address ( 192.168.33.11 ). Soon that will change. We plan to add a 2nd address to the nic eg (192.168.33.33 ) . Some traffic will be routed to it on each address.

Right now it is simple - one address - Caddy listens on multiple ports and responds accordingly . But we are trying to understand how to configure it so Caddy can service 2 different IP addresses and ensure that all response traffic is sent back only via the same ip address… For example where it serves out a webpage on 192.168.33.11:8080 , it would be a different webpage to serve out on 192.168.33.33:8080

Even if anybody can point us to the right section in the documentation about how to configure like this . We have already searched the doc and have not found anything similar. We hope that Caddy can actually do this …

You’re looking for the bind directive which will let you choose which interface to bind to:

1 Like

Thank you for that . We have looked at BIND , but we were not sure if it would be enough. Can you confirm that we can BIND to multiple (eg 2 ) IP addresses at the same time ? Our reading of BIND is that it specifies which (ie singular) IP it is going to BIND to… Did we understand it wrongly ?

Maybe we need to run 2 CaddyServer - one on each IP address ?

Caddy binds to all interfaces by default, i.e. 0.0.0.0.

If you need two different sites to run on two different IPs, then run Caddy something like this:

a.example.com {
	bind 192.168.33.11

	reverse_proxy somewhere:8080
}

b.example.com {
	bind 192.168.33.33

	reverse_proxy elsewhere:8080
}
1 Like

Thank you !!!
That is exactly what we were hoping to have confirmed :smile:

1 Like

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