Caddyserver 2 caddy file

Hi every one

I am going to set up Caddy server 2 this week end.
Would some be able to convert my caddy file from version 1 to Caddy server 2.

Thank you in advance.

address.noip.me address.com address.loginto.me address.zapto.org address.tv address.me address.zapto.org address.co.uk

on startup /caddy/php/php-cgi.exe -b 127.0.0.1:9000 &
fastcgi / 127.0.0.1:9000 php
fastcgi C/caddy/www/monitorr 127.0.0.1:9000 php

root C:\caddy\www

ext .html .htm .php

gzip

proxy /cctv http://127.0.0.1:888 {
transparent
header_upstream X-Forwarded-Host {remote}
}

proxy /calibre http://127.0.0.1:8080 {
transparent
header_upstream X-Forwarded-Host {host}
}
proxy /lazy http://127.0.0.1:5299 {
transparent
header_upstream X-Forwarded-Host {host}
}

proxy /jackett http://127.0.0.1:9117 {
transparent
header_upstream X-Forwarded-Host {host}
}
proxy /lidarr http://127.0.0.1:9898 {
transparent
header_upstream X-Forwarded-Host {host}
}
proxy /htpc http://127.0.0.1:8085 {
transparent
header_upstream X-Forwarded-Host {host}
}

proxy /sabnzbd http://127.0.0.1:8087 {
transparent
header_upstream X-Forwarded-Host {host}
}
proxy /radarr http://127.0.0.1:7878 {
transparent
header_upstream X-Forwarded-Host {host}
}
proxy /sonarr http://127.0.0.1:8981 {
transparent
header_upstream X-Forwarded-Host {host}
}
proxy /nzbhydra http://127.0.0.1:5075 {
header_upstream X-Forwarded-For {remote}
}
proxy /web http://127.0.0.1:32400 {
transparent
header_upstream X-Forwarded-Host {host}
}
proxy /plexpy http://127.0.0.1:8181 {
transparent
header_upstream X-Forwarded-Host {host}
}

rewrite {
if_op or
if {>Referer} has /deluge
if {>Referer} has /localhost/themes/css/
if {>Referer} has /localhost/css/
to /deluge/{path}
}

proxy /deluge http://127.0.0.1:8112 {
without /deluge
transparent
header_upstream X-Forwarded-Host {host}
}
rewrite {
if_op or
if {>Referer} has /organizr
if {>Referer} has /localhost/themes/css/
if {>Referer} has /localhost/css/
to /organizr/{path}
}

proxy /organizr http://127.0.0.1:32771 {
without /organizr
transparent
header_upstream X-Forwarded-Host {host}
}
proxy /nzbhydra2 127.0.0.1:5076/ {
transparent
header_upstream X-Forwarded-Host {host}
}
rewrite / {
#Rewrite URLs without trailing slash
regexp ^/nzbhydra2$
to /nzbhydra2/
}

What have you tried so far?

Hi Mat not a lot.
I was hoping to get a head start with the caddy file.
Iknow you guys are good at this and im not that tech savvy.

Isn’t Caddy v2 supposed to just use a Caddyfile transparently?

I don’t understand your question.

Caddy v2 also uses Caddyfiles for configuration, but v1 Caddyfiles are not comparible with v2. There were significant architectural changes that made it impossible to keep things the same, and there were countless changes we wanted to make to improve the syntax of the Caddyfile as well.

Caddyfiles in v2 still use the similar syntax, but most directives have changed in significant ways.

1 Like

Yo just to throw a few tips at you, in case you’re still stuck:

on startup /caddy/php/php-cgi.exe -b 127.0.0.1:9000 &

This one’s out in the v2 Caddyfile, no equivalent functionality.

fastcgi / 127.0.0.1:9000 php
fastcgi C/caddy/www/monitorr 127.0.0.1:9000 php

wat.jpg

This second one makes basically no sense to me.

But, combined, you can replicate their functionality with: php_fastcgi 127.0.0.1:9000

Root is the same.

Proxies are simpler - all you need is: reverse_proxy /cctv* 127.0.0.1:888

Proxies in v2 come with most of the v1 transparent behaviour by default, no need to specify it.

Rewrites should be done with a named matcher, see documentation: Request matchers (Caddyfile) — Caddy Documentation

It’d look something like this:

@delugeReferer {
  header Referer */deluge*
  header Referer */localhost/themes/css/*
  header Referer */localhost/css*
}
rewrite @delugeReferer /deluge{uri}

To do without, you need to rewrite before the proxy. For that to happen it needs to be in a route so the ordering is handled correctly. The format looks like this:

route /organizr* {
  uri strip_prefix /organizr
  reverse_proxy 127.0.0.1:32771
}

Don’t forget there is a general v1 → v2 upgrade guide here with more info along these lines, too: Upgrading to Caddy 2 — Caddy Documentation

1 Like

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