Jellyfin+Home-Network+Cloudflare v1 to v2 Caddy Setup

1. My Caddy version (caddy version):

I’m Currently running Caddy v1 this issue is for updating my v1 caddyfile config to
Caddy v2 RC3

2. How I run Caddy:

the way i run it currently on Windows 10 administrative command line. i move the cmd to the correct location of the caddy directory. So cd c:\caddy\
then i type in cmd: start caddy.bat
the caddy.bat v1 contains
setlocal
set CLOUDFLARE_EMAIL=email@hotmail.com
set CLOUDFLARE_API_KEY=124561a5c9ed335db96f2b15697f32996e6c5 (#dont worry this is old and is not my current api key)
start caddy -conf caddyfile
My Caddy v2 contains
setlocal
set CLOUDFLARE_EMAIL=cloudflare email
set CLOUDFLARE_API_KEY=cloudflare api key
start caddy
(ive removed the adapter and --config flag because apparently in caddy v2 its not needed because caddy v2 automatically defaults to using caddyfile when running. Plus my caddyfile and caddy.bat are located in the location of C:\caddy)

a. System environment:

Windows 10 X64 CMD and i also have WSL if need be.

b. Command:

start caddy.bat

c. Service/unit/compose file:

d. My complete Caddyfile or JSON config:

caddyfile v1

    requests.movies4you.digital {
        gzip
        log C:\caddy\log\ombi_access.log {
            rotate_size 5          # Rotate after 5 MB
            rotate_age  7          # Keep log files for 7 days
            rotate_keep 2          # Keep at most 2 log files
            rotate_compress     
        }
        proxy / localhost:5000 {
            websocket
            transparent
        }
        tls {
            dns cloudflare
        }
    }
    accounts.movies4you.digital {
        gzip
        log C:\caddy\log\accounts_access.log {
            rotate_size 5          # Rotate after 5 MB
            rotate_age  7          # Keep log files for 7 days
            rotate_keep 2          # Keep at most 2 log files
            rotate_compress     
        }
        proxy / localhost:8056 {         
            websocket
            transparent
        }
        tls {
            dns cloudflare
        }
    }
    stream.movies4you.digital {
        gzip
        log C:\caddy\log\jellyfin_access.log {
            rotate_size 5          # Rotate after 5 MB
            rotate_age  7          # Keep log files for 7 days
            rotate_keep 2          # Keep at most 2 log files
            rotate_compress     
        }
        proxy / localhost:8096 {         
            websocket
            transparent
        }
        tls {
            dns cloudflare
        }
    }

caddyfile v2

    requests.movies4you.digital {
        encode gzip
        output file accounts_access.log {
            roll_size 5MiB
            roll_age 7
            roll_keep 2
            rotate_compress     
        }
      	reverse_proxy /* 127.0.0.1:5000 {
        }
        tls {
            dns cloudflare
        }
    }
    accounts.movies4you.digital {
        encode gzip
        output file accounts_access.log {
            roll_size 5MiB
            roll_age 7
            roll_keep 2
            rotate_compress     
        }
        reverse_proxy /* 127.0.0.1:8056 {         
        }
        tls {
            dns cloudflare
        }
    }
    stream.movies4you.digital {
        encode gzip
        output file accounts_access.log {
            roll_size 5MiB
            roll_age 7
            roll_keep 2
            rotate_compress     
        }
        reverse_proxy /* 127.0.0.1:8096 {         
        }
        tls {
            dns cloudflare
        }
    }

3. The problem I’m having:

im currently just running a reverse proxy on a home network. and i need it to work as intended in v1 in v2 if possible.
i want to first make sure all my settings are correctly configured. Second i wanted to make sure they are going to work with web apps im using. My caddy file is set a specific way for specific reason. for example. Jellyfins base url and subdomains are a bit wonky and i dont think they have fixed them yet in the webui. So for right now. i used stream.movies4you.digital at the top. and my cloudflare handles the cnames and linking of my ip adress to the domain. I also have reverse_proxy /* 127.0.0.1:8096 setup for a reason too. Like i said jellyfins media servers have a hard time with sub domain and their ui doesnt like to work with basurl settings. So for example on my v1 proxy / localhost:8096
it delegates to stream.movies4you.digital if i didnt have that slash it woudnt work.something about their propogation and subdomains with a trailing slash do not work. So i edited in v2 with the same but i have to put a * after the /
atleast i think i do to make it work with v2 update.
If you need my cloudflare info ill be more than happy to update with some screenshots.

4. Error messages and/or full log output:

i dont have any yet i want to make sure everything is correctly setup before uninstalling v1 and installing v2

5. What I already tried:

What ive already explained above

6. Links to relevant resources:

Caddy | Documentation - Jellyfin Project (i dont know how accurate this is because again jellyfin im pretty sure has non working base url in their webui)

Hey @DevilsCoder, welcome to the Caddy community. Few thoughts:

start here is the batch command to run a program. You’re just running caddy on its own, but if you do that in v2, you’ll just get generic help output, after which Caddy will exit.

You probably want caddy run instead.

There is no output directive. You need log.

I note that you seem to have taken the syntax specifically from log (Caddyfile directive) — Caddy Documentation as a complete example, but that’s not the case. That’s only partial syntax. You need to take that and combine it with the rest of the log directive as specified near the top of the page.

Other than those two things, not much I can see that can cause any issues.

1 Like

Seconding what Matthew already said, and adding, you can remove /* and { } as they are unnecessary.

Take a gander at the docs, too: Command Line — Caddy Documentation and log (Caddyfile directive) — Caddy Documentation will help!

1 Like

so in my caddy.bat i should put on the last line start run caddy
becuase the way cmd works is through start commands i think. So would it be

[quote=“Whitestrake, post:2, topic:7757, full:true”]
Hey @DevilsCoder, welcome to the Caddy community. Few thoughts:

start here is the batch command to run a program. You’re just running caddy on its own, but if you do that in v2, you’ll just get generic help output, after which Caddy will exit.

You probably want caddy run instead.

There is no output directive. You need log.

I note that you seem to have taken the syntax specifically from log (Caddyfile directive) — Caddy Documentation as a complete example, but that’s not the case. That’s only partial syntax. You need to take that and combine it with the rest of the log directive as specified near the top of the page.

Other than those two things, not much I can see that can cause any issues.
so in my caddy.bat i should have the last line say “start run caddy” or “run caddy”
because in Windows 10 cmd when i type run caddy in the directory used by caddyfile it says its not a valid running command. So i just want to make sure i have the correct command to put in the .bat and the correct command to run it in cmd. can you explain in some more user friendly informatoin about the output
There is no output directive. You need log
is that you saying i need to make a directory like ‘log C:\caddy\log\jellyfin_access.log’
and matt im also replacing /* with { } or does something need to go in the brackets. Also were still able to use cloudflare like as described in my post correct.
so basically im changing the caddy.bat to say

"setlocal
set CLOUDFLARE_EMAIL=(email@example.com)
set CLOUDFLARE_API_KEY=(cloud api key)
run caddy "

and for the caddyfile:
" requests.movies4you.digital {
encode gzip
log C:\caddy\log\ombi_access.log {
roll_size 5MiB
roll_age 7
roll_keep 2
rotate_compress
}
reverse_proxy 127.0.0.1:5000
tls {
dns cloudflare
}
}
accounts.movies4you.digital {
encode gzip
log C:\caddy\log\accounts_access.log {
roll_size 5MiB
roll_age 7
roll_keep 2
rotate_compress
}
reverse_proxy 127.0.0.1:8056
tls {
dns cloudflare
}
}
stream.movies4you.digital {
encode gzip
log C:\caddy\log\jellyfin_access.log {
roll_size 5MiB
roll_age 7
roll_keep 2
rotate_compress
}
reverse_proxy 127.0.0.1:8096
tls {
dns cloudflare
}
}"
would this be right sorry for the late response i was super exhausted and just woke up from being up for 36hrs.

Change run caddy to start caddy run.

start is a BATCH command. It’s effectively saying: "start a process with x, where x is whatever you specified with the syntax start <x>.

caddy run is the way you actually want to start Caddy. Just running caddy on its own won’t get you much.

So, start <x>, where x is caddy run, equals start caddy run.


Nope, I’m saying this block doesn’t work, on its own, although it’s close:

        output file accounts_access.log {
            roll_size 5MiB
            roll_age 7
            roll_keep 2
            rotate_compress     
        }

And this block on its own won’t work at all, either:

log C:\caddy\log\jellyfin_access.log {
roll_size 5MiB
roll_age 7
roll_keep 2
rotate_compress
}

Go back to the log documentation and go over the syntax again, specifically:

log {
	output <writer_module> ...
	format <encoder_module> ...
	level  <level>
}

log (Caddyfile directive) — Caddy Documentation

See how we simply have log, then open a braced block? See how output is a subdirective of the log directive? Now check the further elaboration on the output subdirective:

output file <filename> {
	roll_disabled
	roll_size     <size>
	roll_keep     <num>
	roll_keep_for <days>
}

log (Caddyfile directive) — Caddy Documentation

This syntax needs to go inside the log directive’s block. It must be nested.

1 Like

thank you for the extreme. Detail it was very much appreicated and very good to know i have fixed the logs does everything else look ok from then on. As well as do i have to uninstall caddy v1 is there a certain procedure for windows because i know i change the enviroment variable in mycomputer—Properties-----Adavnce System Settings—Enviroment Variables and edit paths or can i just run the caddy v2 through nssm

if thats all correct i ran with all the corrected syntax and i type in an elevated command prompt cd c:\caddy\ ------- start caddy.bat and i get

c:\Caddy>setlocal

c:\Caddy>set CLOUDFLARE_EMAIL=(my cloudflare email)
c:\Caddy>set CLOUDFLARE_API_KEY=(my api key)

c:\Caddy>start caddy run

c:\Caddy>
nothing happens after any idea why?
theres also no log created nor ouput text besides what you see above

Hmm, not sure.

This is where my Windows knowledge falls over, I’m afraid. I don’t run my services in batch files, I’m not sure where to look to troubleshoot that.

Maybe it has something to do with start ? Doesn’t that command run your program in a new window? If so, any Caddy errors that would cause it to exit would be in a different window than the one you ran the batch file.

Hopefully someone else here on the forums might have some input.

Right i made sure i made a fresh restart then tried a test run on my windows how would you suggest starting the caddyfile with cloudflare information thats integrated through the caddyfile not the caddy.bat file? thank you for the quick response and thorough information. Its much appreciated again!
would something like a matcher for the subdomain be required and a query for the cloudflare key and cloudflare email. If so can you please give me an example to go off of. Sorry i dont quite get the documentation.

sorry for the second message. Ive done some digging and found out the log is still having issues. When i type on reload caddy in an elevated CMD I get this error 2020/05/01 17:20:03.335 e[34mINFOe[0m using adjacent Caddyfile
reload: adapting config using caddyfile: parsing caddyfile tokens for ‘log’: Caddyfile:5 - Error during parsing: unrecognized subdirective: rotate_size

I will also post my config again one moment

requests.movies4you.digital {
    encode gzip
    log {
        output file C:\caddy\log\ombi_access.log 
        roll_size 150MiB          # Rotate after 5 MB
        roll_age  7          # Keep log files for 7 days
        roll_keep 2          # Keep at most 2 log files
    }
    reverse_proxy 127.0.0.1:5000 {
    }
    tls {
        dns cloudflare
    }
}
accounts.movies4you.digital {
    encode gzip
    log {
        output file C:\caddy\log\accounts_access.log  
        roll_size 150MiB          # Rotate after 5 MB
        roll_age  7          # Keep log files for 7 days
        roll_keep 2          # Keep at most 2 log files     
    }
    reverse_proxy 127.0.0.1:8056 {
    }
    tls {
        dns cloudflare
    }
}
stream.movies4you.digital {
    encode gzip
    log {
        output file C:\caddy\log\jellyfin_access.log 
        roll_size 150MiB          # Rotate after 5 MB
        roll_age  7          # Keep log files for 7 days
        roll_keep 2          # Keep at most 2 log files
        }
    reverse_proxy 127.0.0.1:8096 { 
    }
    tls {
        dns cloudflare
    }
}

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