WoJ
(WoJ)
May 9, 2019, 1:35pm
1
I use caddy
to proxify traffic to docker containers and would like to restrict access based on IPs. I cannot use plugins, so the optimal way would be to conditionally rewrite to a proxy
if {remote} starts_with 192.168 then proxy / x.x.x.x
The else
does not matter, provided the traffic is not sent to x.x.x.x
.
Is this something possible to do?
It’s not too difficult. You were pretty close to the mark in the other post that you deleted.
There’s two ways about it:
A) Proxy by default, forbidding bad clients
proxy / upstream
rewrite {
if {remote} not_starts_with 192.168
to /forbidden
}
status 403 /forbidden
B) Do something else by default (e.g. serve files), but proxy good clients:
root /var/www/html
rewrite {
if {remote} starts_with 192.168
to /proxy
}
proxy /proxy upstream {
without /proxy
}
1 Like
matt
(Matt Holt)
May 10, 2019, 9:34pm
3
FYI, this is much easier (and makes way more sense) in Caddy 2.
WoJ
(WoJ)
May 13, 2019, 3:50pm
4
@matt Thank you - I will have a closer look to Caddy 2 now that I have deployed it successfully on my home servers.
system
(system)
Closed
August 11, 2019, 3:50pm
5
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.