1. Caddy version (caddy version
): v2.0.0
2. How I run Caddy:
a. System environment:
b. Command:
sudo caddy reload
c. Service/unit/compose file:
I use pm2 for my next.js app, started with this command:
pm2 start npm --name "next" -- start
d. My complete Caddyfile or JSON config:
Caddyfile:
:80
reverse_proxy /* localhost:3000
JSON config (from caddy adapt
):
{"apps":{"http":{"servers":{"srv0":{"listen":[":80"],"routes":[{"handle":[{"handler":"reverse_proxy","upstreams":[{"dial":"localhost:3000"}]}]}]}}}}}
3. The problem I’m having:
I am trying to setup a Next.js app on my VPS but for some reason all routes except /
return 521 error. I want the caddy server to serve all pages under :3000. I use Cloudflare with A
record pointed to my server IP.
4. Error messages and/or full log output:
020/06/06 13:10:42.677 INFO using adjacent Caddyfile
2020/06/06 13:10:42.680 INFO admin admin endpoint started {"address": "tcp/localhost:2019", "enforce_origin": false, "origins": ["localhost:2019", "[::1]:2019", "127.0.0.1:2019"]}
2020/06/06 13:10:42.680 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": 80}
2020/06/06 13:10:42.682 INFO tls cleaned up storage units
2020/06/06 13:10:42.683 INFO autosaved config {"file": "/root/.config/caddy/autosave.json"}
2020/06/06 13:10:42.683 INFO serving initial configuration
2020/06/06 13:10:42 [INFO] Started certificate maintenance routine
Successfully started Caddy - Caddy is running in the background
5. What I already tried:
I tried different configs.
This:
:80
reverse_proxy :3000
this:
:80
route /* {
reverse_proxy localhost:3000
}
and this:
:80 {
reverse_proxy localhost:3000
}
they all didn’t work