Migrate from nginx to caddy2

1. Caddy version (caddy version):


2. How I run Caddy:

caddy-api on ubuntu vm

a. System environment:

ubuntu 20.04

b. Command:

systemctl start caddy-api

c. Service/unit/compose file:

# caddy-api.service
# For using Caddy with its API.
# This unit is "durable" in that it will automatically resume
# the last active configuration if the service is restarted.
# See https://caddyserver.com/docs/install for instructions.


ExecStart=/usr/bin/caddy run --environ --resume


d. My complete Caddyfile or JSON config:


3. The problem I’m having:

I’m not quite sure if this is possible in caddy but I’m moving my our internal rproxy solution from nginx to caddy and I’m stuck on one configuration and I’m not quite sure it is possible to do the same in caddy, here is the “tricky” part (for me at least)

if ($args ~ entryPoint=campaign_trackerv2) {
  rewrite  ^/(.*)$ /$1 last;

The rest of the nginx configuration is already adapt to caddy as it is basic reverse proxy stuff.
I am not the original editor of the nginx conf but already been told it is mandatory…

I tried to use nginx-adapter but does not seem to work anymore.

Thanks in advance for your help.


I don’t use nginx myself, but I generally have an idea of what bits in the config do… but this one looks foreign to me. What is it supposed to do exactly? I’m sure Caddy can do it but I need to understand the goal.

Hello Françis,
Apologize for not answering earlier.
As far as I can understand this nginx directive it does nothing this is why I ask about the pertinence of this rewrite… I do not have any answer from people yet.
I think I won’t convert it to caddy as it doe not seem to be “mandatory”.

^/(.)$ : What is between first / and the end
Replaced by /$1 ($1 : Regex writing just on top(.

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