1. Output of caddy version
:
v2.6.1 h1:EDqo59TyYWhXQnfde93Mmv4FJfYe00dO60zMiEt+pzo=
2. How I run Caddy:
I installed Cddy using sudo apt install caddy
on my Ubuntu server, and I run it as a systemctl service.
a. System environment:
OS: Ubuntu 22.04 x64
b. Command:
systemctl reload caddy
c. Service/unit/compose file:
Paste full file contents here.
Make sure backticks stay on their own lines,
and the post looks nice in the preview pane. -->
d. My complete Caddy config:
/etc/caddy/example.com
example.com {
root * /var/www/html/example.com
file_server
# 404 errors
handle_errors {
@404 {
expression {http.error.status_code} == 404
}
rewrite @404 /404.html
file_server
}
}
www.example.com {
redir https://example.com{uri} permanent
}
/etc/caddy/tools.example.com
tools.example.com {
reverse_proxy 127.0.0.1:4000
}
/etc/caddy/Caddyfile
:80 {
# Set this path to your site's directory.
root * /usr/share/caddy
# Enable the static file server.
file_server
# Another common task is to set up a reverse proxy:
# reverse_proxy localhost:8080
# Or serve a PHP site through php-fpm:
# php_fastcgi localhost:9000
}
# example.com
import ./example.com
# tools.example.com
import ./tools.example.com
3. The problem I’m having:
So I have a static website hosted at example.com and a NodeJS app with a reverse proxy on tools.example.com (see above Caddyfiles).
I want that if someone visits example.com/tools, they are shown the tools.example.com site, without changing the URL (so not a redirect).
4. Error messages and/or full log output:
Paste logs/commands/output here.
USE THE PREVIEW PANE TO MAKE SURE IT LOOKS NICELY FORMATTED.
5. What I already tried:
I’ve tried rewrite /tools to https://tools.example.com
and rewrite /tools to 127.0.0.1:4000