# caddy.service
#
# For using Caddy with a config file.
#
# Make sure the ExecStart and ExecReload commands are correct
# for your installation.
#
# See https://caddyserver.com/docs/install for instructions.
#
# WARNING: This service does not use the --resume flag, so if you
# use the API to make changes, they will be overwritten by the
# Caddyfile next time the service is restarted. If you intend to
# use Caddy's API to configure it, add the --resume flag to the
# `caddy run` command or use the caddy-api.service file instead.
[Unit]
Description=Caddy
Documentation=https://caddyserver.com/docs/
After=network.target network-online.target
Requires=network-online.target
[Service]
Type=notify
User=caddy
Group=caddy
ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile
ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE
[Install]
WantedBy=multi-user.target
I’m trying to run Umami, a web analyzer running as a node.js server as a proxy in my Caddyserver. Umami is running at http://localhost:3000, the main site is running fine, Adminer, too. But I can’t get the reverse proxy working.
Using / as your matcher will only match requests to exactly /. You probably want to remove the / so that it applies to all requests. See the request matcher docs:
You can simplify all this by using a single site block:
Thanks for these great hints, that simplifies the Caddyfile a lot!
The logs from the journalctl command stop after Caddy has started. I added a log directive to the reverse-proxy directive but got nothing after putting the URL in my browser.
The curl command gives a lot of direct output:
* Expire in 0 ms for 6 (transfer 0x5604dcec8e20)
* Expire in 1 ms for 1 (transfer 0x5604dcec8e20)
* Expire in 0 ms for 1 (transfer 0x5604dcec8e20)
* Expire in 1 ms for 1 (transfer 0x5604dcec8e20)
* Expire in 0 ms for 1 (transfer 0x5604dcec8e20)
* Expire in 0 ms for 1 (transfer 0x5604dcec8e20)
* Expire in 1 ms for 1 (transfer 0x5604dcec8e20)
* Expire in 0 ms for 1 (transfer 0x5604dcec8e20)
* Expire in 0 ms for 1 (transfer 0x5604dcec8e20)
* Expire in 1 ms for 1 (transfer 0x5604dcec8e20)
* Expire in 0 ms for 1 (transfer 0x5604dcec8e20)
* Expire in 0 ms for 1 (transfer 0x5604dcec8e20)
* Expire in 1 ms for 1 (transfer 0x5604dcec8e20)
* Expire in 0 ms for 1 (transfer 0x5604dcec8e20)
* Expire in 0 ms for 1 (transfer 0x5604dcec8e20)
* Expire in 1 ms for 1 (transfer 0x5604dcec8e20)
* Expire in 0 ms for 1 (transfer 0x5604dcec8e20)
* Expire in 0 ms for 1 (transfer 0x5604dcec8e20)
* Expire in 1 ms for 1 (transfer 0x5604dcec8e20)
* Expire in 0 ms for 1 (transfer 0x5604dcec8e20)
* Expire in 0 ms for 1 (transfer 0x5604dcec8e20)
* Expire in 1 ms for 1 (transfer 0x5604dcec8e20)
* Expire in 0 ms for 1 (transfer 0x5604dcec8e20)
* Expire in 0 ms for 1 (transfer 0x5604dcec8e20)
* Expire in 0 ms for 1 (transfer 0x5604dcec8e20)
* Trying 131.220.93.76...
* TCP_NODELAY set
* Expire in 200 ms for 4 (transfer 0x5604dcec8e20)
* Connected to production.germanistik.uni-bonn.de (131.220.93.76) port 2021 (#0)
> GET / HTTP/1.1
> Host: production.germanistik.uni-bonn.de:2021
> User-Agent: curl/7.64.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: text/html; charset=utf-8
< Date: Mon, 26 Jul 2021 23:21:33 GMT
< Etag: "b67-1K60jeYDjII+5TAdQGYaHGybBy4"
< Server: Caddy
< Vary: Accept-Encoding
< X-Powered-By: Next.js
< Transfer-Encoding: chunked
<
<!DOCTYPE html><html><head><meta charSet="utf-8"/><link rel="icon" href="/favicon.ico"/><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"/><link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"/><link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"/><link rel="manifest" href="/site.webmanifest"/><link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5"/><meta name="msapplication-TileColor" content="#da532c"/><meta name="theme-color" content="#ffffff"/><meta name="viewport" content="width=device-width, initial-scale=1"/><meta name="next-head-count" content="10"/><link rel="preload" href="/_next/static/css/25adb5e26976efabfed6.css" as="style"/><link rel="stylesheet" href="/_next/static/css/25adb5e26976efabfed6.css" data-n-g=""/><noscript data-n-css=""></noscript><link rel="preload" href="/_next/static/chunks/webpack-50bee04d1dc61f8adf5b.js" as="script"/><link rel="preload" href="/_next/static/chunks/framework.6fff953eb0f638171baa.js" as="script"/><link rel="preload" href="/_next/static/chunks/commons.699dc7725c4ffa5b6d2c.js" as="script"/><link rel="preload" href="/_next/static/chunks/main-5ff3205d3e3be766ed2d.js" as="script"/><link rel="preload" href="/_next/static/chunks/79da0455c8b3e567442e3b7dcf3faf24cc347e75.2cbed7047107a95a8790.js" as="script"/><link rel="preload" href="/_next/static/chunks/f19fd3195dd04850b965ac06991a07274f604423.7a0274925ea5c4511fea.js" as="script"/><link rel="preload" href="/_next/static/chunks/pages/_app-6d21a792c0f2ca2d7cd3.js" as="script"/><link rel="preload" href="/_next/static/chunks/pages/index-060f525e3b4a9bbbcd2b.js" as="script"/></head><body><div id="__next"></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{}},"page":"/","query":{},"buildId":"ya1WSBTQLRdzMVvqaQWWw","nextExport":true,"autoExport":true,"isFallback":false}</script><script nomodule="" src="/_next/static/chunks/polyfills-3fa9f7fa683372911569.js"></script><script src="/_next/static/chunks/webpack-50bee04d1dc61f8adf5b.js* Connection #0 to host production.germanistik.uni-bonn.de left intact
" async=""></script><script src="/_next/static/chunks/framework.6fff953eb0f638171baa.js" async=""></script><script src="/_next/static/chunks/commons.699dc7725c4ffa5b6d2c.js" async=""></script><script src="/_next/static/chunks/main-5ff3205d3e3be766ed2d.js" async=""></script><script src="/_next/static/chunks/79da0455c8b3e567442e3b7dcf3faf24cc347e75.2cbed7047107a95a8790.js" async=""></script><script src="/_next/static/chunks/f19fd3195dd04850b965ac06991a07274f604423.7a0274925ea5c4511fea.js" async=""></script><script src="/_next/static/chunks/pages/_app-6d21a792c0f2ca2d7cd3.js" async=""></script><script src="/_next/static/chunks/pages/index-060f525e3b4a9bbbcd2b.js" async=""></script><script src="/_next/static/ya1WSBTQLRdzMVvqaQWWw/_buildManifest.js" async=""></script><script src="/_next/static/ya1WSBTQLRdzMVvqaQWWw/_ssgManifest.js" async=""></script></body></html>
But that’s only with curl. When I put the URL in the browser, Firefox gets a timeout (Opera too, Brave too): Website not reachable (or something like that, in German), ERR_CONNECTION_TIMED_OUT