How can I add a X-Real-IP header to the above config?
4. Error messages and/or full log output:
Jan 19 20:18:52 caddy caddy[2393]: reload: adapting config using caddyfile: /etc/caddy/Caddyfile:82: unrecognized directive: header_up
Jan 19 20:18:52 caddy systemd[1]: caddy.service: Control process exited, code=exited, status=1/FAILURE
Are you sure you need to add X-Real-IP? Caddy already provides it via X-Forwarded-For, automatically:
It seems like you have at least 82 lines in your Caddyfile, so you clearly haven’t shared the whole thing. Please don’t redact your Caddyfile, it’s difficult to talk about incomplete information.
Hi sorry but its various sites repeated like this in the config: mydomain.com, www.mydomain.com {
reverse_proxy 11.22.33.44
import wordpress
}
And on one of the sites I added header_up config as show on my example above and i got this error.
(wordpress) {
# Redirect to remove “www.” since wordpress doesn’t
# like multi-domain visits. @strip_www {
header_regexp www Host ^www.(.*)$
}
redir @strip_www https://{http.regexp.www.1}{uri}
# Some static files Cache-Control. @static {
path *.ico *.css *.js *.gif *.jpg *.jpeg *.png *.svg *.woff .json
}
header @static Cache-Control max-age=2592000 @cache {
not header_regexp Cookie “comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in”
not path_regexp "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-..php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(index)?.xml|[a-z0-9-]±sitemap([0-9]+)?.xml)"
not method POST
not expression {query} != ‘’
}
route @cache {
try_files /wp-content/cache/supercache/{host}{uri}/index-https.html /wp-content/cache/supercache/{host}{uri}/index.html {path} {path}/index.php?{query}
}
# Change the path here according to your server #php_fastcgi unix//run/php/php7.4-fpm.sock
# Use this header if you use something like WPML
# If you are running a single domain simple site you can remove this.
header Access-Control-Allow-Origin *
encode zstd gzip
file_server
}
After looking at your example and comparing to my config i noticed that I did not have a space on this part
reverse_proxy 11.22.33.44 {
mine was
reverse_proxy 11.22.33.44{
Thanks once again for great support.
Now that you see my wordpress part, do you see any issues with it?
For next time, please use ``` on the lines before and after your config/logs, to use code formatting. Configs should not be in quote blocks, but in code blocks, to preserve whitespace. It’s very difficult to read otherwise.