Caddy reverse-proxy + docker in Goodle Cloud Run

1. Output of caddy version:

v2.6.2 h1:wKoFIxpmOJLGl3QXoo6PNbYvGW4xLEgo32GPBEjWL8o=

2. How I run Caddy:

I wanted to use Caddy as a reverse proxy as proposed here: Deploying a reverse proxy to PostHog Cloud - Docs - PostHog
I want to host Caddy in Google Cloud run, I had to create a Dockerfile and Caddyfile

The Google Cloud Run service I use has enabled domain mapping to https://analytics.openfort.xyz

a. System environment:

Docker and Google Cloud Run

b. Command:

Using Docker

c. Service/unit/compose file:

FROM caddy:alpine

COPY ./Caddyfile /etc/caddy/Caddyfile

d. My complete Caddy config:

{
    email my@email.com
 
}

:{$PORT} {
    
   reverse_proxy eu.posthog.com:443
 
}

3. The problem I’m having:

I want to use Caddy as a reverse proxy as suggested here: Deploying a reverse proxy to PostHog Cloud - Docs - PostHog
I want to host it in Cloud run

4. Error messages and/or full log output:

{
    "insertId": "63c13a7400062548eff5ba43",
    "jsonPayload": {
      "config_file": "/etc/caddy/Caddyfile",
      "msg": "using provided configuration",
      "config_adapter": "caddyfile",
      "level": "info",
      "ts": 1673607796.4025066
    },
    "resource": {
      "type": "cloud_run_revision",
      "labels": {
        "configuration_name": "reverse-proxy",
        "revision_name": "reverse-proxy-00018-mox",
        "project_id": "openfort",
        "service_name": "reverse-proxy",
        "location": "europe-west1"
      }
    },
    "timestamp": "2023-01-13T11:03:16.402760Z",
    "labels": {
      "instanceId": "0071bb481510cd7b427188423e59274e3534b509a36a0826e4038c80264bbae6957a27e1479e233c5703ee03fd77173ebfe2d6548112b09c2d8dcf46ead43e3a39",
      "gcb-trigger-id": "6c5dfb5c-b7d3-427d-9371-cb61bdc1fcd6",
      "managed-by": "gcp-cloud-build-deploy-cloud-run",
      "gcb-build-id": "402c7566-69af-423b-80ff-7a1439f3d35b",
      "commit-sha": "17c2a96d653aead529683a8e8f0222b6adf75627"
    },
    "logName": "projects/openfort/logs/run.googleapis.com%2Fstderr",
    "receiveTimestamp": "2023-01-13T11:03:16.408647863Z"
  },
  {
    "insertId": "63c13a74000633dd3488a5d4",
    "jsonPayload": {
      "file": "/etc/caddy/Caddyfile",
      "level": "warn",
      "msg": "Caddyfile input is not formatted; run the 'caddy fmt' command to fix inconsistencies",
      "adapter": "caddyfile",
      "line": 2,
      "ts": 1673607796.4063733
    },
    "resource": {
      "type": "cloud_run_revision",
      "labels": {
        "configuration_name": "reverse-proxy",
        "project_id": "openfort",
        "service_name": "reverse-proxy",
        "location": "europe-west1",
        "revision_name": "reverse-proxy-00018-mox"
      }
    },
    "timestamp": "2023-01-13T11:03:16.406493Z",
    "labels": {
      "gcb-trigger-id": "6c5dfb5c-b7d3-427d-9371-cb61bdc1fcd6",
      "commit-sha": "17c2a96d653aead529683a8e8f0222b6adf75627",
      "instanceId": "0071bb481510cd7b427188423e59274e3534b509a36a0826e4038c80264bbae6957a27e1479e233c5703ee03fd77173ebfe2d6548112b09c2d8dcf46ead43e3a39",
      "managed-by": "gcp-cloud-build-deploy-cloud-run",
      "gcb-build-id": "402c7566-69af-423b-80ff-7a1439f3d35b"
    },
    "logName": "projects/openfort/logs/run.googleapis.com%2Fstderr",
    "receiveTimestamp": "2023-01-13T11:03:16.742761064Z"
  },
  {
    "insertId": "63c13a74000649c4f1a778f9",
    "jsonPayload": {
      "logger": "admin",
      "ts": 1673607796.4119742,
      "level": "info",
      "enforce_origin": false,
      "origins": [
        "//localhost:2019",
        "//[::1]:2019",
        "//127.0.0.1:2019"
      ],
      "msg": "admin endpoint started",
      "address": "localhost:2019"
    },
    "resource": {
      "type": "cloud_run_revision",
      "labels": {
        "location": "europe-west1",
        "project_id": "openfort",
        "revision_name": "reverse-proxy-00018-mox",
        "configuration_name": "reverse-proxy",
        "service_name": "reverse-proxy"
      }
    },
    "timestamp": "2023-01-13T11:03:16.412100Z",
    "labels": {
      "commit-sha": "17c2a96d653aead529683a8e8f0222b6adf75627",
      "instanceId": "0071bb481510cd7b427188423e59274e3534b509a36a0826e4038c80264bbae6957a27e1479e233c5703ee03fd77173ebfe2d6548112b09c2d8dcf46ead43e3a39",
      "managed-by": "gcp-cloud-build-deploy-cloud-run",
      "gcb-trigger-id": "6c5dfb5c-b7d3-427d-9371-cb61bdc1fcd6",
      "gcb-build-id": "402c7566-69af-423b-80ff-7a1439f3d35b"
    },
    "logName": "projects/openfort/logs/run.googleapis.com%2Fstderr",
    "receiveTimestamp": "2023-01-13T11:03:16.742761064Z"
  },
  {
    "insertId": "63c13a7400064d9256b7d815",
    "jsonPayload": {
      "level": "info",
      "logger": "http",
      "ts": 1673607796.4129958,
      "msg": "server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS",
      "server_name": "srv0",
      "https_port": 443
    },
    "resource": {
      "type": "cloud_run_revision",
      "labels": {
        "project_id": "openfort",
        "location": "europe-west1",
        "configuration_name": "reverse-proxy",
        "service_name": "reverse-proxy",
        "revision_name": "reverse-proxy-00018-mox"
      }
    },
    "timestamp": "2023-01-13T11:03:16.413074Z",
    "labels": {
      "commit-sha": "17c2a96d653aead529683a8e8f0222b6adf75627",
      "managed-by": "gcp-cloud-build-deploy-cloud-run",
      "instanceId": "0071bb481510cd7b427188423e59274e3534b509a36a0826e4038c80264bbae6957a27e1479e233c5703ee03fd77173ebfe2d6548112b09c2d8dcf46ead43e3a39",
      "gcb-trigger-id": "6c5dfb5c-b7d3-427d-9371-cb61bdc1fcd6",
      "gcb-build-id": "402c7566-69af-423b-80ff-7a1439f3d35b"
    },
    "logName": "projects/openfort/logs/run.googleapis.com%2Fstderr",
    "receiveTimestamp": "2023-01-13T11:03:16.742761064Z"
  },
  {
    "insertId": "63c13a7400064da365deb28d",
    "jsonPayload": {
      "level": "info",
      "msg": "enabling automatic HTTP->HTTPS redirects",
      "ts": 1673607796.4130394,
      "server_name": "srv0",
      "logger": "http"
    },
    "resource": {
      "type": "cloud_run_revision",
      "labels": {
        "configuration_name": "reverse-proxy",
        "revision_name": "reverse-proxy-00018-mox",
        "location": "europe-west1",
        "service_name": "reverse-proxy",
        "project_id": "openfort"
      }
    },
    "timestamp": "2023-01-13T11:03:16.413091Z",
    "labels": {
      "gcb-trigger-id": "6c5dfb5c-b7d3-427d-9371-cb61bdc1fcd6",
      "instanceId": "0071bb481510cd7b427188423e59274e3534b509a36a0826e4038c80264bbae6957a27e1479e233c5703ee03fd77173ebfe2d6548112b09c2d8dcf46ead43e3a39",
      "gcb-build-id": "402c7566-69af-423b-80ff-7a1439f3d35b",
      "commit-sha": "17c2a96d653aead529683a8e8f0222b6adf75627",
      "managed-by": "gcp-cloud-build-deploy-cloud-run"
    },
    "logName": "projects/openfort/logs/run.googleapis.com%2Fstderr",
    "receiveTimestamp": "2023-01-13T11:03:16.742761064Z"
  },
  {
    "insertId": "63c13a74000652a09c7b5e89",
    "jsonPayload": {
      "cache": "0xc000237f10",
      "msg": "started background certificate maintenance",
      "level": "info",
      "ts": 1673607796.4142904,
      "logger": "tls.cache.maintenance"
    },
    "resource": {
      "type": "cloud_run_revision",
      "labels": {
        "configuration_name": "reverse-proxy",
        "project_id": "openfort",
        "revision_name": "reverse-proxy-00018-mox",
        "service_name": "reverse-proxy",
        "location": "europe-west1"
      }
    },
    "timestamp": "2023-01-13T11:03:16.414368Z",
    "labels": {
      "instanceId": "0071bb481510cd7b427188423e59274e3534b509a36a0826e4038c80264bbae6957a27e1479e233c5703ee03fd77173ebfe2d6548112b09c2d8dcf46ead43e3a39",
      "commit-sha": "17c2a96d653aead529683a8e8f0222b6adf75627",
      "managed-by": "gcp-cloud-build-deploy-cloud-run",
      "gcb-build-id": "402c7566-69af-423b-80ff-7a1439f3d35b",
      "gcb-trigger-id": "6c5dfb5c-b7d3-427d-9371-cb61bdc1fcd6"
    },
    "logName": "projects/openfort/logs/run.googleapis.com%2Fstderr",
    "receiveTimestamp": "2023-01-13T11:03:16.742761064Z"
  },
  {
    "insertId": "63c13a74000656fa0877f8ce",
    "jsonPayload": {
      "logger": "http",
      "ts": 1673607796.4154103,
      "addr": ":443",
      "msg": "enabling HTTP/3 listener",
      "level": "info"
    },
    "resource": {
      "type": "cloud_run_revision",
      "labels": {
        "configuration_name": "reverse-proxy",
        "revision_name": "reverse-proxy-00018-mox",
        "service_name": "reverse-proxy",
        "location": "europe-west1",
        "project_id": "openfort"
      }
    },
    "timestamp": "2023-01-13T11:03:16.415482Z",
    "labels": {
      "managed-by": "gcp-cloud-build-deploy-cloud-run",
      "gcb-trigger-id": "6c5dfb5c-b7d3-427d-9371-cb61bdc1fcd6",
      "instanceId": "0071bb481510cd7b427188423e59274e3534b509a36a0826e4038c80264bbae6957a27e1479e233c5703ee03fd77173ebfe2d6548112b09c2d8dcf46ead43e3a39",
      "gcb-build-id": "402c7566-69af-423b-80ff-7a1439f3d35b",
      "commit-sha": "17c2a96d653aead529683a8e8f0222b6adf75627"
    },
    "logName": "projects/openfort/logs/run.googleapis.com%2Fstderr",
    "receiveTimestamp": "2023-01-13T11:03:16.742761064Z"
  },
  {
    "insertId": "63c13a7400065c9cfa698330",
    "jsonPayload": {
      "protocols": [
        "h1",
        "h2",
        "h3"
      ],
      "level": "info",
      "logger": "http.log",
      "ts": 1673607796.4168425,
      "name": "srv0",
      "msg": "server running"
    },
    "resource": {
      "type": "cloud_run_revision",
      "labels": {
        "configuration_name": "reverse-proxy",
        "revision_name": "reverse-proxy-00018-mox",
        "project_id": "openfort",
        "location": "europe-west1",
        "service_name": "reverse-proxy"
      }
    },
    "timestamp": "2023-01-13T11:03:16.416924Z",
    "labels": {
      "managed-by": "gcp-cloud-build-deploy-cloud-run",
      "gcb-trigger-id": "6c5dfb5c-b7d3-427d-9371-cb61bdc1fcd6",
      "gcb-build-id": "402c7566-69af-423b-80ff-7a1439f3d35b",
      "instanceId": "0071bb481510cd7b427188423e59274e3534b509a36a0826e4038c80264bbae6957a27e1479e233c5703ee03fd77173ebfe2d6548112b09c2d8dcf46ead43e3a39",
      "commit-sha": "17c2a96d653aead529683a8e8f0222b6adf75627"
    },
    "logName": "projects/openfort/logs/run.googleapis.com%2Fstderr",
    "receiveTimestamp": "2023-01-13T11:03:16.742761064Z"
  },
  {
    "insertId": "63c13a7400065d46b560f751",
    "jsonPayload": {
      "msg": "server running",
      "protocols": [
        "h1",
        "h2",
        "h3"
      ],
      "ts": 1673607796.4170384,
      "level": "info",
      "name": "srv1",
      "logger": "http.log"
    },
    "resource": {
      "type": "cloud_run_revision",
      "labels": {
        "revision_name": "reverse-proxy-00018-mox",
        "location": "europe-west1",
        "configuration_name": "reverse-proxy",
        "project_id": "openfort",
        "service_name": "reverse-proxy"
      }
    },
    "timestamp": "2023-01-13T11:03:16.417094Z",
    "labels": {
      "managed-by": "gcp-cloud-build-deploy-cloud-run",
      "instanceId": "0071bb481510cd7b427188423e59274e3534b509a36a0826e4038c80264bbae6957a27e1479e233c5703ee03fd77173ebfe2d6548112b09c2d8dcf46ead43e3a39",
      "gcb-trigger-id": "6c5dfb5c-b7d3-427d-9371-cb61bdc1fcd6",
      "gcb-build-id": "402c7566-69af-423b-80ff-7a1439f3d35b",
      "commit-sha": "17c2a96d653aead529683a8e8f0222b6adf75627"
    },
    "logName": "projects/openfort/logs/run.googleapis.com%2Fstderr",
    "receiveTimestamp": "2023-01-13T11:03:16.742761064Z"
  },
  {
    "insertId": "63c13a7400065d88d3538f2e",
    "jsonPayload": {
      "level": "info",
      "name": "remaining_auto_https_redirects",
      "protocols": [
        "h1",
        "h2",
        "h3"
      ],
      "msg": "server running",
      "ts": 1673607796.4171174,
      "logger": "http.log"
    },
    "resource": {
      "type": "cloud_run_revision",
      "labels": {
        "revision_name": "reverse-proxy-00018-mox",
        "service_name": "reverse-proxy",
        "project_id": "openfort",
        "configuration_name": "reverse-proxy",
        "location": "europe-west1"
      }
    },
    "timestamp": "2023-01-13T11:03:16.417160Z",
    "labels": {
      "instanceId": "0071bb481510cd7b427188423e59274e3534b509a36a0826e4038c80264bbae6957a27e1479e233c5703ee03fd77173ebfe2d6548112b09c2d8dcf46ead43e3a39",
      "gcb-trigger-id": "6c5dfb5c-b7d3-427d-9371-cb61bdc1fcd6",
      "commit-sha": "17c2a96d653aead529683a8e8f0222b6adf75627",
      "managed-by": "gcp-cloud-build-deploy-cloud-run",
      "gcb-build-id": "402c7566-69af-423b-80ff-7a1439f3d35b"
    },
    "logName": "projects/openfort/logs/run.googleapis.com%2Fstderr",
    "receiveTimestamp": "2023-01-13T11:03:16.742761064Z"
  },
  {
    "insertId": "63c13a7400065d951b86ce1f",
    "jsonPayload": {
      "ts": 1673607796.4171312,
      "level": "info",
      "logger": "http",
      "msg": "enabling automatic TLS certificate management",
      "domains": [
        "debug"
      ]
    },
    "resource": {
      "type": "cloud_run_revision",
      "labels": {
        "configuration_name": "reverse-proxy",
        "project_id": "openfort",
        "revision_name": "reverse-proxy-00018-mox",
        "service_name": "reverse-proxy",
        "location": "europe-west1"
      }
    },
    "timestamp": "2023-01-13T11:03:16.417173Z",
    "labels": {
      "managed-by": "gcp-cloud-build-deploy-cloud-run",
      "instanceId": "0071bb481510cd7b427188423e59274e3534b509a36a0826e4038c80264bbae6957a27e1479e233c5703ee03fd77173ebfe2d6548112b09c2d8dcf46ead43e3a39",
      "gcb-build-id": "402c7566-69af-423b-80ff-7a1439f3d35b",
      "gcb-trigger-id": "6c5dfb5c-b7d3-427d-9371-cb61bdc1fcd6",
      "commit-sha": "17c2a96d653aead529683a8e8f0222b6adf75627"
    },
    "logName": "projects/openfort/logs/run.googleapis.com%2Fstderr",
    "receiveTimestamp": "2023-01-13T11:03:16.742761064Z"
  },
  {
    "insertId": "63c13a74000660218ada1573",
    "jsonPayload": {
      "level": "info",
      "ts": 1673607796.4177763,
      "msg": "autosaved config (load with --resume flag)",
      "file": "/config/caddy/autosave.json"
    },
    "resource": {
      "type": "cloud_run_revision",
      "labels": {
        "project_id": "openfort",
        "service_name": "reverse-proxy",
        "location": "europe-west1",
        "revision_name": "reverse-proxy-00018-mox",
        "configuration_name": "reverse-proxy"
      }
    },
    "timestamp": "2023-01-13T11:03:16.417825Z",
    "labels": {
      "commit-sha": "17c2a96d653aead529683a8e8f0222b6adf75627",
      "managed-by": "gcp-cloud-build-deploy-cloud-run",
      "gcb-build-id": "402c7566-69af-423b-80ff-7a1439f3d35b",
      "instanceId": "0071bb481510cd7b427188423e59274e3534b509a36a0826e4038c80264bbae6957a27e1479e233c5703ee03fd77173ebfe2d6548112b09c2d8dcf46ead43e3a39",
      "gcb-trigger-id": "6c5dfb5c-b7d3-427d-9371-cb61bdc1fcd6"
    },
    "logName": "projects/openfort/logs/run.googleapis.com%2Fstderr",
    "receiveTimestamp": "2023-01-13T11:03:16.742761064Z"
  },
  {
    "insertId": "63c13a740006602e5fcdf51f",
    "jsonPayload": {
      "msg": "serving initial configuration",
      "level": "info",
      "ts": 1673607796.4177935
    },
    "resource": {
      "type": "cloud_run_revision",
      "labels": {
        "project_id": "openfort",
        "location": "europe-west1",
        "configuration_name": "reverse-proxy",
        "service_name": "reverse-proxy",
        "revision_name": "reverse-proxy-00018-mox"
      }
    },
    "timestamp": "2023-01-13T11:03:16.417838Z",
    "labels": {
      "gcb-build-id": "402c7566-69af-423b-80ff-7a1439f3d35b",
      "gcb-trigger-id": "6c5dfb5c-b7d3-427d-9371-cb61bdc1fcd6",
      "commit-sha": "17c2a96d653aead529683a8e8f0222b6adf75627",
      "managed-by": "gcp-cloud-build-deploy-cloud-run",
      "instanceId": "0071bb481510cd7b427188423e59274e3534b509a36a0826e4038c80264bbae6957a27e1479e233c5703ee03fd77173ebfe2d6548112b09c2d8dcf46ead43e3a39"
    },
    "logName": "projects/openfort/logs/run.googleapis.com%2Fstderr",
    "receiveTimestamp": "2023-01-13T11:03:16.742761064Z"
  },
  {
    "insertId": "63c13a74000662a1c8442148",
    "jsonPayload": {
      "logger": "tls.obtain",
      "identifier": "debug",
      "level": "info",
      "msg": "acquiring lock",
      "ts": 1673607796.4184139
    },
    "resource": {
      "type": "cloud_run_revision",
      "labels": {
        "project_id": "openfort",
        "location": "europe-west1",
        "service_name": "reverse-proxy",
        "configuration_name": "reverse-proxy",
        "revision_name": "reverse-proxy-00018-mox"
      }
    },
    "timestamp": "2023-01-13T11:03:16.418465Z",
    "labels": {
      "commit-sha": "17c2a96d653aead529683a8e8f0222b6adf75627",
      "gcb-build-id": "402c7566-69af-423b-80ff-7a1439f3d35b",
      "gcb-trigger-id": "6c5dfb5c-b7d3-427d-9371-cb61bdc1fcd6",
      "instanceId": "0071bb481510cd7b427188423e59274e3534b509a36a0826e4038c80264bbae6957a27e1479e233c5703ee03fd77173ebfe2d6548112b09c2d8dcf46ead43e3a39",
      "managed-by": "gcp-cloud-build-deploy-cloud-run"
    },
    "logName": "projects/openfort/logs/run.googleapis.com%2Fstderr",
    "receiveTimestamp": "2023-01-13T11:03:16.742761064Z"
  },
  {
    "insertId": "63c13a740006640dcafebcab",
    "jsonPayload": {
      "logger": "tls.obtain",
      "identifier": "debug",
      "level": "info",
      "msg": "lock acquired",
      "ts": 1673607796.4187589
    },
    "resource": {
      "type": "cloud_run_revision",
      "labels": {
        "configuration_name": "reverse-proxy",
        "project_id": "openfort",
        "location": "europe-west1",
        "service_name": "reverse-proxy",
        "revision_name": "reverse-proxy-00018-mox"
      }
    },
    "timestamp": "2023-01-13T11:03:16.418829Z",
    "labels": {
      "gcb-build-id": "402c7566-69af-423b-80ff-7a1439f3d35b",
      "commit-sha": "17c2a96d653aead529683a8e8f0222b6adf75627",
      "instanceId": "0071bb481510cd7b427188423e59274e3534b509a36a0826e4038c80264bbae6957a27e1479e233c5703ee03fd77173ebfe2d6548112b09c2d8dcf46ead43e3a39",
      "managed-by": "gcp-cloud-build-deploy-cloud-run",
      "gcb-trigger-id": "6c5dfb5c-b7d3-427d-9371-cb61bdc1fcd6"
    },
    "logName": "projects/openfort/logs/run.googleapis.com%2Fstderr",
    "receiveTimestamp": "2023-01-13T11:03:16.742761064Z"
  },
  {
    "insertId": "63c13a740006650d621950ab",
    "jsonPayload": {
      "logger": "tls.obtain",
      "level": "info",
      "msg": "obtaining certificate",
      "identifier": "debug",
      "ts": 1673607796.418989
    },
    "resource": {
      "type": "cloud_run_revision",
      "labels": {
        "configuration_name": "reverse-proxy",
        "location": "europe-west1",
        "revision_name": "reverse-proxy-00018-mox",
        "project_id": "openfort",
        "service_name": "reverse-proxy"
      }
    },
    "timestamp": "2023-01-13T11:03:16.419085Z",
    "labels": {
      "instanceId": "0071bb481510cd7b427188423e59274e3534b509a36a0826e4038c80264bbae6957a27e1479e233c5703ee03fd77173ebfe2d6548112b09c2d8dcf46ead43e3a39",
      "managed-by": "gcp-cloud-build-deploy-cloud-run",
      "gcb-trigger-id": "6c5dfb5c-b7d3-427d-9371-cb61bdc1fcd6",
      "gcb-build-id": "402c7566-69af-423b-80ff-7a1439f3d35b",
      "commit-sha": "17c2a96d653aead529683a8e8f0222b6adf75627"
    },
    "logName": "projects/openfort/logs/run.googleapis.com%2Fstderr",
    "receiveTimestamp": "2023-01-13T11:03:16.742761064Z"
  },
  {
    "insertId": "63c13a74000675146ba4c780",
    "jsonPayload": {
      "level": "info",
      "ts": 1673607796.4230888,
      "msg": "cleaning storage unit",
      "logger": "tls",
      "description": "FileStorage:/data/caddy"
    },
    "resource": {
      "type": "cloud_run_revision",
      "labels": {
        "revision_name": "reverse-proxy-00018-mox",
        "location": "europe-west1",
        "project_id": "openfort",
        "service_name": "reverse-proxy",
        "configuration_name": "reverse-proxy"
      }
    },
    "timestamp": "2023-01-13T11:03:16.423188Z",
    "labels": {
      "instanceId": "0071bb481510cd7b427188423e59274e3534b509a36a0826e4038c80264bbae6957a27e1479e233c5703ee03fd77173ebfe2d6548112b09c2d8dcf46ead43e3a39",
      "managed-by": "gcp-cloud-build-deploy-cloud-run",
      "gcb-trigger-id": "6c5dfb5c-b7d3-427d-9371-cb61bdc1fcd6",
      "commit-sha": "17c2a96d653aead529683a8e8f0222b6adf75627",
      "gcb-build-id": "402c7566-69af-423b-80ff-7a1439f3d35b"
    },
    "logName": "projects/openfort/logs/run.googleapis.com%2Fstderr",
    "receiveTimestamp": "2023-01-13T11:03:16.742761064Z"
  },
  {
    "insertId": "63c13a740006756ccaef2f4e",
    "jsonPayload": {
      "level": "info",
      "msg": "finished cleaning storage units",
      "logger": "tls",
      "ts": 1673607796.4232364
    },
    "resource": {
      "type": "cloud_run_revision",
      "labels": {
        "project_id": "openfort",
        "location": "europe-west1",
        "revision_name": "reverse-proxy-00018-mox",
        "configuration_name": "reverse-proxy",
        "service_name": "reverse-proxy"
      }
    },
    "timestamp": "2023-01-13T11:03:16.423276Z",
    "labels": {
      "gcb-build-id": "402c7566-69af-423b-80ff-7a1439f3d35b",
      "commit-sha": "17c2a96d653aead529683a8e8f0222b6adf75627",
      "managed-by": "gcp-cloud-build-deploy-cloud-run",
      "gcb-trigger-id": "6c5dfb5c-b7d3-427d-9371-cb61bdc1fcd6",
      "instanceId": "0071bb481510cd7b427188423e59274e3534b509a36a0826e4038c80264bbae6957a27e1479e233c5703ee03fd77173ebfe2d6548112b09c2d8dcf46ead43e3a39"
    },
    "logName": "projects/openfort/logs/run.googleapis.com%2Fstderr",
    "receiveTimestamp": "2023-01-13T11:03:16.742761064Z"
  },
]

5. What I already tried:

{
    email my@email.com
 
}

:{$PORT} {
    
   reverse_proxy eu.posthog.com:443
 
}

with curl -v https://analytics.openfort.xyz output:

*   Trying 142.250.201.83:443...
* Connected to analytics.openfort.xyz (142.250.201.83) port 443 (#0)
* ALPN: offers h2
* ALPN: offers http/1.1
*  CAfile: /etc/ssl/cert.pem
*  CApath: none
* (304) (OUT), TLS handshake, Client hello (1):
* (304) (IN), TLS handshake, Server hello (2):
* (304) (IN), TLS handshake, Unknown (8):
* (304) (IN), TLS handshake, Certificate (11):
* (304) (IN), TLS handshake, CERT verify (15):
* (304) (IN), TLS handshake, Finished (20):
* (304) (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / AEAD-CHACHA20-POLY1305-SHA256
* ALPN: server accepted h2
* Server certificate:
*  subject: CN=analytics.openfort.xyz
*  start date: Jan 11 18:28:50 2023 GMT
*  expire date: Apr 11 19:12:16 2023 GMT
*  subjectAltName: host "analytics.openfort.xyz" matched cert's "analytics.openfort.xyz"
*  issuer: C=US; O=Google Trust Services LLC; CN=GTS CA 1D4
*  SSL certificate verify ok.
* Using HTTP2, server supports multiplexing
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* h2h3 [:method: GET]
* h2h3 [:path: /]
* h2h3 [:scheme: https]
* h2h3 [:authority: analytics.openfort.xyz]
* h2h3 [user-agent: curl/7.85.0]
* h2h3 [accept: */*]
* Using Stream ID: 1 (easy handle 0x12a00c600)
> GET / HTTP/2
> Host: analytics.openfort.xyz
> user-agent: curl/7.85.0
> accept: */*
>
< HTTP/2 400
< content-type: text/html
< via: 1.1 9f63706579db7391acaa39a0dddcff5e.cloudfront.net (CloudFront)
< x-amz-cf-id: 3qmnVVKynAUNMMw4Vs6SZtslKIcd_O64pH6Si-HvxUbWPUq_5O77Lg==
< x-amz-cf-pop: CDG3-C2
< x-cache: Error from cloudfront
< x-cloud-trace-context: ec4faf911b39f5d7bbe568d574488467
< date: Fri, 13 Jan 2023 11:03:44 GMT
< server: Google Frontend
< content-length: 915
<
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The request could not be satisfied</TITLE>
</HEAD><BODY>
<H1>400 ERROR</H1>
<H2>The request could not be satisfied.</H2>
<HR noshade size="1px">
Bad request.
We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
<BR clear="all">
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.
<BR clear="all">
<HR noshade size="1px">
<PRE>
Generated by cloudfront (CloudFront)
Request ID: 3qmnVVKynAUNMMw4Vs6SZtslKIcd_O64pH6Si-HvxUbWPUq_5O77Lg==
</PRE>
<ADDRESS>
</ADDRESS>
* Connection #0 to host analytics.openfort.xyz left intact
</BODY></HTML>

If I then change the reverse_proxy url to https://eu.posthog.com:

{
    email my@email.com
 
}

:{$PORT} {
    
   reverse_proxy https://eu.posthog.com
 
}

I get the following error:

When I change the --from url to analytics.openfort.xyz,

{
    email my@email.com
 
}

analytics.openfort.xyz {
    
   reverse_proxy eu.posthog.com:443
 
}

the service fails to build with error:

ERROR: (gcloud.run.services.update) The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable. Logs for this revision might contain more information.

I’ve also tried adding auto_https off, but I still get the 400 Error.

6. Links to relevant resources:

I’ve read the following forum post on using caddy with Cloud run https://caddy.community/t/caddy-works-with-google-cloud-run/6898 and it worked fine with the example that is provided, but I just can’t manage to get it to work with the reverse proxy.

Is that all the logs you have? That only looks like the logs from Caddy’s startup, and nothing else after.

Try enabling the debug global option, it might show more.

FYI, Caddy’s reverse_proxy is HTTP by default. If you mean to proxy over HTTPS, you should use the https:// scheme, and also override the Host header. See the docs:

This will make Caddy listen for HTTP on whatever port that is.

(In that case, the email global option doesn’t do anything for you.)

This tells Caddy to try to automate issuance of a certificate for analytics.openfort.xyz.

Which one is your intent? Did you want Caddy to handle TLS? Or just unencrypted HTTP traffic?

I don’t know how Cloud Run works. Does it act as an HTTP proxy itself? Does it handle any of your traffic? Or do they just give you an IP address for your running container that you point your domain to?

Thanks, that solved it.

This is the configuration that worked for me with cloud run with domain mapping to a subdomain:

Docker file:

FROM caddy:alpine

COPY ./Caddyfile /etc/caddy/Caddyfile

Caddyfile

{
        # email jaume@openfort.xyz
}
:{$PORT} {
        reverse_proxy https://eu.posthog.com {
                header_up Host {upstream_hostport}
        }
}
1 Like