1. Caddy version (caddy version
):
caddy version
(devel)
2. How I run Caddy:
Dockerfile
....
FROM alpine:latest
# we are installing caddy using curl + bash
# so here come the dependencies
RUN apk add --no-cache \
bash \
curl \
caddy
EXPOSE 443
CMD ["caddy","run", "--config", "/etc/Caddyfile"]
....
a. System environment:
inside a docker of alpine:latest
b. Command:
CMD ["caddy","run", "--config", "/etc/Caddyfile"]
c. Service/unit/compose file:
version: '3'
services:
client:
container_name: client
image: test_client:latest
restart: always
ports:
- "80:80"
- "443:443"
links:
- express
volumes:
- /home/opc/persist/.caddy:/root/.caddy
express:
container_name: express
build: express
image: test_express:latest
environment:
- NODE_ENV=test
restart: always
d. My complete Caddyfile or JSON config:
:443 {
tls /etc/caddy/cert.pem /etc/caddy/key.pem
log {
output file /var/log/caddylog.log
}
root * /var/www/html
file_server
encode gzip
route /api* {
uri strip_prefix /api
reverse_proxy express:3000 {
header_up Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
}
}
header /api ?Cache-Control
}
3. The problem I’m having:
The webapp itself works great. However, there is a route that requests under “share” path cannot access.
In the caddy1 version, our Caddyfile did enable it:
{$PRIVATE_IP}:80 {$CADDY_SUBDOMAIN}.companyname.com:443 {
tls /etc/caddy/cert.pem /etc/caddy/key.pem
log /oapi stdout "{remote} {method} {uri} {proto} {status} {size} {latency_ms}"
log /share stdout "{remote} {method} {uri} {proto} {status} {size} {latency_ms}"
errors
root /var/www/html
gzip
proxy /api express:3000 {
without /api
transparent
}
proxy /share express:3000/share {
without /share
transparent
}
header / {
-Server
X-Frame-Options "DENY"
Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
Cache-Control "max-age=259200"
}
header /agroapi -Cache-Control
header /share -Cache-Control
header /api -Cache-Control
}
4. Error messages and/or full log output:
in the browser:
This test.companyname.com page can’t be foundNo webpage was found for the web address: https://test.companyname.com/**share**/finding/7260613/user/7
HTTP ERROR 404
5. What I already tried:
tryout 1):
route /api/share* {
uri strip_prefix /api/share
reverse_proxy express:3000/share {
header_up Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
}
}
tryout 2):
reverse_proxy /share/* express:3000/share {
header_up Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
}
The need for this “shared” is to expose resources to users that are not logged into the webapp.
I guess the update from caddy1 to latest missed this part.
Thanks!