Your Caddyfile doesn’t make much sense – there’s no use to use both file_server and reverse_proxy at the same time, without request matchers. And you don’t need any of the header_up lines, they’re actually harmful in many cases. You can simplify it to this:
:80 {
reverse_proxy 127.0.0.1:100080
}
That said, the reason you’re seeing Docker’s IP is because Docker often puts a userland proxy in front of containers, which transforms the TCP packets before they reach Caddy, making it look like the requests came from Docker itself. You can turn this off in Docker’s settings.
Next time, please fill out the help topic template. There’s bits missing from your post which make it confusing, e.g. how are you running the Caddy container, which version of Caddy are you running, etc.
According to GitHub - mpolden/echoip: IP address lookup service you have to apply an option to specify which header should be used to get the ip address (else the command doesn’t use any of the headers):
-H value
Header to trust for remote IP, if present (e.g. X-Real-IP)
So the command to start the ifconfig.co container should be:
docker run -p 10080:8080 -d -v /tmp/geo/:/tmp/geo/ mpolden/echoip -c /tmp/geo/GeoLite2-City.mmdb -f /tmp/geo/GeoLite2-Country.mmdb -a /tmp/geo/GeoLite2-ASN.mmdb -H X-Forwarded-For
FYI this probably won’t do what you expect. This will configure two upstreams, one being ip.69b.ir and the other 127.0.0.1:10080. Caddy will randomly pick one for each request.
In this case, I don’t think you mean to use two. So change it to just reverse_proxy 127.0.0.1:10080.
saeb@mobin-13991227 ~> cat /etc/caddy/Caddyfile
# The Caddyfile is an easy way to configure your Caddy web server.
#
# Unless the file starts with a global options block, the first
# uncommented line is always the address of your site.
#
# To use your own domain name (with automatic HTTPS), first make
# sure your domain's A/AAAA DNS records are properly pointed to
# this machine's public IP, then replace ":80" below with your
# domain name.
ip.saeb.sbs:80 {
reverse_proxy localhost:10080
}
:80 {
root * /usr/share/caddy
file_server
}