1. The problem I’m having:
We’re transfering our webservice-logic to Caddy(v2). I need to map a remote server into the local server URL-space ( a classical /api endpoint ), I did this in Apache like this:
<Location /api>
ProxyPass https://api-{{ customer }}.mywebsite.com/api
ProxyPassReverse https://api-{{ customer }}.mywebsite.com/api
Require all granted
</Location>
But i’m not sure how to the same in Caddy. I tried:
handle /api* {
reverse_proxy https://api-{{ customer }}.mywebsite.com
}
But this does behave different than ProxyPass. Which parameter do i need to mimic the behavior from Apache?
3. Caddy version:
v2.6.4
a. System environment:
Static hostname: web-stack-test
Icon name: computer-vm
Chassis: vm
Virtualization: kvm
Operating System: Ubuntu 20.04.5 LTS
Kernel: Linux 5.4.0-144-generic
Architecture: x86-64
d. My complete Caddy config:
{
servers {
metrics
}
}
api-{{ customer }}.mywebsite.com {
metrics /metrics
root * /var/www/api/{{ customer }}/htdocs
file_server
php_fastcgi 127.0.0.1:9000
log {
output file /var/log/caddy/api-{{ customer }}.mywebsite.com.log {
roll_size 100mb
roll_keep 5
roll_keep_for 720h
}
}
}
{{ customer }}.mywebsite.com {
metrics /metrics
handle {
root * /var/www/html
file_server
php_fastcgi 127.0.0.1:9001
}
handle /api* {
reverse_proxy https://api-{{ customer }}.mywebsite.com
}
log {
output file /var/log/caddy/{{ customer }}.mywebsite.com.log {
roll_size 100mb
roll_keep 5
roll_keep_for 720h
}
}
}
5. Links to relevant resources:
https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxypass