Problems with caddy2 and reverse_proxy rewrite

1. Caddy version (caddy version):


2. How I run Caddy:

a. System environment:

Ubuntu 18.04.2 LTS

b. Command:

I use systemd.

c. Service/unit/compose file:

# caddy.service
# For using Caddy with a config file.
# Make sure the ExecStart and ExecReload commands are correct
# for your installation.
# 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.


ExecStart=/usr/local/bin/caddy run --environ --config /etc/caddy2/Caddyfile
ExecReload=/usr/local/bin/caddy reload --config /etc/caddy2/Caddyfile


d. My complete Caddyfile or JSON config: {
  rewrite /explore /
  reverse_proxy localhost:3000

3. The problem I’m having:

With Caddy1, I could use the following Caddyfile to redirect /explore to /. With the above config in Caddy2, I can’t get this to work.

Caddyfile for caddy1 (works): {
   proxy / localhost:3000
   rewrite /explore /

4. Error messages and/or full log output:

Jul 10 19:07:27 git3 caddy[13018]: {"level":"error","ts":1594408047.454012,"logger":"http.handlers.reverse_proxy","msg":"aborting with incomplete response","error":"context canceled"}

I get this message every time I load a page.

5. What I already tried:

I tried removing the rewrite line, and does not seem to make any difference with the above error.

What is the full request you are making? (please give a curl command or a full dump of the request’s method, uri, headers, and body)

If I load the following URL in a browser:

I want Caddy to redirect to

Essentially, prevent /explore from being accessed.

This is the problem I’m trying to work around:

actually it is working, but I had to make the following change to get /explore/repos to redirect to / as well: {
  rewrite /explore/* /
  reverse_proxy localhost:3000

The reason I did not think it was working before was my browser must have been put in BEC Git Server when I was testing. Looks like all is well now. Sorry for the false alarm.


This topic was automatically closed after 30 days. New replies are no longer allowed.