Does caddy have http realip module by default?

1. Caddy version (caddy version):

v2.4.5

2. How I run Caddy:

I installed caddy as following

echo "deb [trusted=yes] https://apt.fury.io/caddy/ /" \
    | sudo tee -a /etc/apt/sources.list.d/caddy-fury.list
sudo apt-get update -y
sudo apt-get install caddy -y

a. System environment:

Debian 10.

b. Command:

sudo service caddy

d. My complete Caddyfile or JSON config:

domains.com {
tls noreply@domains.com
 reverse_proxy 127.0.0.1:3000 {
  header_up Host {http.request.host}
  header_up X-Real-IP {http.request.remote}
  header_up X-Forwarded-For {http.request.remote}
  header_up X-Forwarded-Port {http.request.port}
  header_up X-Forwarded-Proto {http.request.scheme}
 }
}

3. The problem I’m having:

4. Error messages and/or full log output:

5. What I already tried:

6. Links to relevant resources:

Thank you.

Please upgrade to v2.4.6!

Please switch to using our CloudSmith repo. We’ll eventually stop pushing updates to the fury.io repo.

Remove all these lines, Caddy will automatically set the appropriate proxy headers.

Why do you need this? What are you trying to do? Caddy will pass the X-Forwarded-For header upstream which will have the client’s IP address.

Hey, I use CloudFlare as the proxy and it needs http realip module. X-Forwarded-For doesn’t work with CloudFlare.

In nginx.conf, I set real_ip_header CF-Connecting-IP;.

Thank you.

There’s no built-in way to replace the remote address with the value from a header, but there is a plugin that can do it: GitHub - kirsch33/realip: realip module for Caddy v2. Keep in mind, the plugin has a couple known bugs.

Thank you so much.

I seem to have come across a new situation, I removed caddy with old version from /etc/caddy, /usr/bin/caddy and /usr/share/caddy. And also I removed caddy-fury.list from /etc/apt/sources.list.d and then I followed the following steps install caddy

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo tee /etc/apt/trusted.gpg.d/caddy-stable.asc
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy

And I get the information, it seems that caddy is installed successfully.

Reading package lists... Done
Building dependency tree
Reading state information... Done
caddy is already the newest version (2.4.6).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

But I can’t find the caddy, which caddy returns caddy not found and whereis caddy returns caddy:.

BTW, if I already have caddy installed on my system and I want to install a third party caddy plugin from github, like this one https://github.com/kirsch33/realip how do I install it? Thank you so much.

1 Like

You’re supposed to run apt remove caddy first before installing again. Removing files by hand isn’t right.

To get a build of Caddy with plugins, you can use xcaddy, or download a build from the build server:

1 Like

Thank you so much.

Sorry, I missed something, in your reply you mean if I want to add a third party plug to caddy that has been installed on a server, I should remove caddy and rebuild it with some tools, such as xcaddy, right?

Don’t remove it, instead follow these steps to use a custom build:

I see, thank you so so much.

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