1. My Caddy version (caddy version
):
v2.0.0-beta.14 h1:QX1hRMfTA5sel53o5SuON1ys50at6yuSAnPr56sLeK8=
2. How I run Caddy:
bin/caddy run -config ~/caddy/conf/default.caddy -adapter caddyfile
a. System environment:
Linux virtual-host-1 5.4.7-arch1-1 #1 SMP PREEMPT Tue, 31 Dec 2019 17:20:16 +0000 x86_64 GNU/Linux
Running as local binary downloaded from Github releases
d. My complete Caddyfile or JSON config:
{
email <redacted>
http_port 9080
https_port 9443
# experimental_http3
acme_ca https://acme-staging-v02.api.letsencrypt.org/directory
}
:9080 {
encode gzip
reverse_proxy /* 127.0.0.1:8123 {
header_up X-Forwarded-For {remote_host}
}
}
:9080/portainer/* {
strip_prefix portainer/
reverse_proxy localhost:9000 {
header_up Host {host}
header_up X-Real-IP {remote_host}
header_up X-Forwarded-For {remote_host}
}
}
3. The problem I’m having:
I’m tryin to route requests from a subfolder path to the root of a service running on another port.
Something I have been doing on Nginx for a long time. See the end of this post for the current, working NGINX config I am trying to recreate.
The “error” is very ambiguous. Caddy is not throwing any error.
When I open the developer console, I can see that it gets the root response. I get a 200 response.
Anything else it tries to get like /portainer/vendor.js
does not load, and I get no error in caddy2
4. Error messages and/or full log output:
2020/02/24 21:21:19.598 INFO using provided configuration {"config_file": "/home/<redact>/caddy/conf/default.caddy", "config_adapter": "caddyfile"}
2020/02/24 21:21:19.602 INFO admin admin endpoint started {"address": "localhost:2019", "enforce_origin": false, "origins": ["localhost:2019"]}
2020/02/24 21:21:19.602 INFO http server is listening only on the HTTP port, so no automatic HTTPS will be applied to this server {"server_name": "srv0", "http_port": 9080}
2020/02/24 13:21:19 [INFO][cache:0xc0000d9360] Started certificate maintenance routine
2020/02/24 21:21:19.604 INFO tls cleaned up storage units
2020/02/24 21:21:19.605 INFO autosaved config {"file": "/home/<redact>/.config/caddy/autosave.json"}
2020/02/24 21:21:19.605 INFO serving initial configuration
5. What I already tried:
Pretty much everything.
Been googling, looking in these forums, and testing all sorts of combinations of the directives and matcher configs in my caddyfile.
None of it seems to work and most guidance I have gotten on this kind of thing is for Caddy V1, and I don’t see a direct translation to Caddy2
6. Links to relevant resources:
server {
listen 443 ssl;
location / {
proxy_pass http://172.17.0.1:8123;
proxy_set_header Host $host;
proxy_redirect http:// https://;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
location /portainer/ {
rewrite ^/portainer(/.*)$ $1 break;
proxy_pass http://172.17.0.1:9000/;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_redirect off;
}
}