1. Caddy version (caddy version
):
2.3.0
2. How I run Caddy:
Docker, using Cloudflare as DNS on rviewit.com
a. System environment:
Ubuntu 18.04.1 LTS, Docker 18.06
b. Command:
docker-compose -f /etc/hasura/docker-compose.yaml up -d
c. Service/unit/compose file:
services:
caddy:
image: caddy/caddy:alpine
depends_on:
- "graphql-engine"
restart: always
ports:
- "80:80"
- "443:443"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- caddy_certs:/root/.caddy
- caddy_data:/data
volumes:
db_data:
caddy_certs:
caddy_data:
d. My complete Caddyfile or JSON config:
api.revddit.com {
tls internal
route /q/* {
uri strip_prefix q/
reverse_proxy 172.17.0.1:9090
}
}
rviewit.com {
tls internal
# log {
# format json
# output stdout
# }
route /api/short/modlogs/* {
uri strip_prefix api/short/modlogs/
header Access-Control-Allow-Origin *
reverse_proxy * modlogs.fyi {
header_up Host {http.reverse_proxy.upstream.hostport}
}
}
route /api/short/* {
uri strip_prefix api/short/
reverse_proxy 172.17.0.1:8383
}
route /api/long/* {
uri strip_prefix api/long/
reverse_proxy 172.17.0.1:8383
}
route /api/* {
uri strip_prefix api/
reverse_proxy 172.17.0.1:8383
}
}
3. The problem I’m having:
Requests matching the first route return status 400, for example this request
4. Error messages and/or full log output:
{
"level": "error",
"ts": 1618132717.0355983,
"logger": "http.log.access.log0",
"msg": "handled request",
"request": {
"remote_addr": "",
"proto": "HTTP/1.1",
"method": "GET",
"host": "rviewit.com",
"uri": "/api/short/modlogs/api/subreddits",
"headers": {
"Cf-Ray": [
"63e320e8ec355ef1-SJC"
],
"Sec-Ch-Ua": [
"\"Google Chrome\";v=\"89\", \"Chromium\";v=\"89\", \";Not A Brand\";v=\"99\""
],
"Sec-Fetch-Site": [
"none"
],
"Sec-Fetch-Dest": [
"document"
],
"Cf-Connecting-Ip": [
""
],
"Cf-Request-Id": [
"0961d2e59200005ef134394000000001"
],
"Accept-Encoding": [
"gzip"
],
"Dnt": [
"1"
],
"User-Agent": [
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36"
],
"Connection": [
"Keep-Alive"
],
"X-Forwarded-For": [
""
],
"X-Forwarded-Proto": [
"https"
],
"Cf-Visitor": [
"{\"scheme\":\"https\"}"
],
"Sec-Ch-Ua-Mobile": [
"?0"
],
"Upgrade-Insecure-Requests": [
"1"
],
"Accept": [
"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"
],
"Sec-Fetch-User": [
"?1"
],
"Accept-Language": [
"en"
],
"Cookie": [
"__cfduid=db7c2d62c2cee927bc9cd06c698a657e41615882696"
],
"Cdn-Loop": [
"cloudflare"
],
"Sec-Fetch-Mode": [
"navigate"
]
},
"tls": {
"resumed": false,
"version": 772,
"cipher_suite": 4865,
"proto": "",
"proto_mutual": true,
"server_name": "rviewit.com"
}
},
"common_log": "162.158.255.131 - - [11/Apr/2021:09:18:37 +0000] \"GET /api/short/modlogs/api/subreddits HTTP/1.1\" 400 155",
"duration": 0.011514512,
"size": 155,
"status": 400,
"resp_headers": {
"Cf-Ray": [
"-"
],
"Date": [
"Sun, 11 Apr 2021 09:18:37 GMT"
],
"Content-Type": [
"text/html"
],
"Server": [
"Caddy",
"cloudflare"
],
"Access-Control-Allow-Origin": [
"*"
],
"Content-Length": [
"155"
]
}
}
5. What I already tried:
Other incarnations of reverse_proxy
in Caddyfile,
reverse_proxy modlogs.fyi
reverse_proxy https://modlogs.fyi:443
...
I read this post’s answer and adjusted it to use header_up Host
as shown above. However, I still get errors. I wonder if it has to do with tls or not.
It was working under Caddy v1, where my Caddyfile was,
http://rviewit.com, https://rviewit.com {
proxy /api/short/modlogs/ https://modlogs.fyi {
without /api/short/modlogs
}
Maybe it has something to do with the tls internal
directive?