Pls, help rewrite nginx config to Caddyfile

There are such lines in my nginx configuration file:

server_name my-server.com;
root /var/www/my-server.com;

location / {
try_files $uri $uri/ /index.html;
}

location ~* ^/(pluto|venus|aurora|vesta|flora|pluto-1|venus-1|aurora-1|vesta-1|flora-1)/(.*)$ {
proxy_buffering off;
proxy_pass https://$1.web.telegram.org/$2;
}

Help to adapt them to the Caddyfile

p.s. sorry for my English

The first two blocks would look like this:

my-server.com {
  root /var/www/my-server.com

  rewrite {
    to {path} {path}/ /index.html
  }
}

The last part gets complicated because of the way it re-uses the first path element as the subdomain of the proxy target.

You’ll need to write an individual proxy for each one, because Caddy doesn’t have a method to manipulate a dynamic proxy target in that manner.

e.g.

proxy /pluto https://pluto.web.telegram.org {
  without /pluto
}

proxy /venus https://venus.web.telegram.org {
  without /venus
}

# ...etc etc
1 Like

Thanks for the help

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.