D&D - Caddy - S2025 E04

Transcript

D\&D - 2025/03/17 12:59 EDT – Transcript

Attendees

David Busby, David Busby's Presentation, david raistrick

Transcript

david raistrick: If I can find sure it was just the easy solution when I needed all of the things. Right.

David Busby: There we go.

David Busby: So, now it's live. So, I was just thinking, since Caddy or you care about Caddy or you told me it was cool, we could do a little jam session on Caddy.

David Busby: needed all the things. I thought we could make it do the FCGI WSU CGI or something. And I got this demo box that right now I thought the easiest thing would be do what the bog standard engine X or…

david raistrick: Right.

David Busby: Apache things do and give me a web route that I can drop a PHP file in that runs right. and then if I can get that to PHP's FCGI mechanism or whichever one Caddy likes, then after that picking a Django mechanism or one of the NodeJS things or possibly even then setting up rewrite rules and sending my requests to all kinds of microervices in, whatever language I feel like running, in

David Busby: my house that is very legacy pearl things and modern stuff that's now written in Go makes that stuff very very very easy.

David Busby: So let's see if I turn on screen share and we'll just look at my node here.

david raistrick: because I think…

david raistrick: where I'm using it I think I'm proxying it back.

david raistrick: I suspect I'm using Apache here. I'm trying to remember It should be easy to tell, right? Yeah. It's all buried in layers of automation.

David Busby: Visit the site and…

David Busby: look at the headers. Unless you turn those headers off, lots of folks do. that's how you do it. so, this thing is there's no caddy in my Debian repo.

david raistrick: Where's my

David Busby: So, the first thing is to put a* into my system. Just run a bunch of commands here without thinking about them too much.

david raistrick: Yeah. Heat.

David Busby: I'm just grabbing all this crap from the Caddy servers website. go stable releases. I'm going to install it. It's probably on my system somewhere. Wonder if it's auto automatically started on some internal port 2019. Doesn't Caddy know it's 2025? and then it also looks like it's started on port 80.

David Busby: So if I go to visit that website that was not responding. Congratulations. Caddy works.

david raistrick: There you go.

David Busby: Caddy is ready to serve your point some stuff. I've done that. Go to varwh and put something there. All right, let's see if that actually works. I have something there.

david raistrick: It's probably that index page. Where's your caddy file?

David Busby: It ain't this caddy de It's a index page for a different demo box completely at It says Etsy caddy file replace this s***. because this is the default and…

david raistrick: Use a share caddy.

David Busby: it says user share caddy is their default and…

David Busby: it's just a static file server. Hey, that's cool. So, I should really be able to just do something like demo.io.com and…

david raistrick: Yeah, I don't know…

David Busby: then why does it say root star? I wonder to the internet.

david raistrick: what the star was for, but I have the same thing in one that I have. I don't remember.

David Busby: Whoops. It's not on my screen Set the root path of the site. This does not automatically enable something.

David Busby: You got to use file server or fast CGI route path is the path to use for the site route. Prior to this argument could be confused for the matcher token if it began. So it was necessary to something something.

00:05:00

david raistrick: We had to make it a star…

david raistrick: because it had to be a star.

David Busby: But if you said something else like you could just say root something change the site.

david raistrick: All requests.

David Busby: So you can match a prefix path and…

david raistrick: Yeah. Right.

David Busby: I'm going to route this prefix into another directory." So you could do something like everybody is in optio caddy demo web route. That's where everything goes. And then do you think they do strictness order or top down?

david raistrick: I believe that it's strictness order.

david raistrick: because I have more specifics below the star in my config…

David Busby:

David Busby: We are gonna So I'm going to do star goes to some normal web route and…

david raistrick: where I'm doing reverse proxies. So yeah,…

David Busby: then foost star goes to a directory called foo route. which doesn't exist at the moment. You think I got to say in the root to do the thing. Let's do file server.

david raistrick: you got to do file server.

David Busby: So you always have to save file server to enable that.

david raistrick: And I think gzip isn't turned on by default. So if you wanted it, you got to enable gzip or encode gzip…

David Busby: Do I have to reload?

david raistrick: if you're into that.

David Busby: No, I don't gzip anything. I think the stuff is empty, too. …

david raistrick: I mean for doing gzip over the wire php.

David Busby:

David Busby: this is what I was looking for. So this is what I expected it to show me because in that caddy demo web route I have index html…

David Busby: which is totally empty. Whoa, I'm so terrible at this demo title,…

david raistrick: I just do cheat HTML.

david raistrick: Leave all the tags though.

David Busby: I know you can do that and I just can't bring myself to not write something that looks sort of okay, …

David Busby: just a nerd like that. So, there's my demo. There is an index.php file.

david raistrick: And you'll notice you have https support.

David Busby: Say again.

david raistrick: You notice you had https support.

David Busby: It already has HTTPS enabled. I didn't even do dude. f******.

david raistrick: Check your certificate on it.

David Busby: Really? …

David Busby: let's check something really quick. Okay, so you go to this and…

david raistrick: If you get a redirect.

david raistrick: You get a redirect. right?

David Busby: I didn't set up s**. This is usually a couple of lines that I fiddle with in EngineX and a couple of lines I fiddle with in Apache. I do add config lines in traffic also. because I don't know if it does SSL by default, but you add one line and boom, you're done, or mostly boom, you're done. But it's not I added zero lines on this one and it gives me a 308 permanent redirect to HTTPS. It doesn't do. I bet I'd have to do something for that htst certificate pinning or…

David Busby: whatever that is. And there I go. Match theertert.

david raistrick: And you have a let's encrypt already dynamically completely 100% already done…

David Busby: …

david raistrick: because it can do the domain verification. So it set up the

David Busby: right after I did the reload of this config, I did a reload. I hit the site. I got an protocol error. Then I flipped over to this terminal window to look at something. Then I went back to the thing and I hit re and I took the S out of the URL and I went, " okay. I'll just go back to HTTP." I hit go and it worked. And I didn't even notice that it had been redirected back to ad SSL magic sauce,…

david raistrick: It did it all for you.

David Busby: Magic sauce.

david raistrick: That is why Caddy server is my number one recommendation for small projects like this because that are you going to use let's encrypt. It took all the work away. You didn't do anything.

David Busby: Yeah, that was pretty handy, so that's like we're getting ahead of ourselves.

david raistrick: I mean if you need custom stuff you can do more custom stuff. You can do mult you can do sands, So you can add additional names to it. you can do wild cards, lots of things. But I forget how to do wild cards. But I think my example doesn't have any wild cards.

00:10:00

david raistrick: but

David Busby: So, it looks like it knows how to handle index html, no problem. and I went to foo root. And then if I go to just slashfu, it gives me a normal old 404. But then if I'd say slash something, no, that doesn't work. If I add the trailing slash, it also gives me a 404. This is for that slashfu pattern I thought we were going to match.

david raistrick: Yeah, I'm not sure.

david raistrick: Let's see. It might have to be something other than root.

David Busby: It says root slash goes to…

David Busby: which does exist.

david raistrick: I'm not sure. Yeah,…

David Busby: Do some typing there.

david raistrick: you have to do a handle path, I think. Or maybe no, that's for the thing to hang on. No, I'm reading the wrong thing.

david raistrick: Yeah, I think you have to do a handle path on that.

David Busby: Let's see what It says I do root star pointing to web routt then say file server and then here's how you turn https off incidentally if you want to…

david raistrick: Yeah. Right.

David Busby: which I don't and then you make this directive at symbol some path slash all right so at fu is the name that I make up path probably seems like a specific keyword I'd have to use and…

david raistrick: And that can be more complicated longer things There's lots of ways that the handlers can be defined.

David Busby: then I say blah blah blah the path I want it to pretend that it is. So let's do root that thing and then file server. I wonder why it makes me put that below the file server directive. I don't like how that then I'll say root at fu I've done that incorrectly it's going to be at fu path is foost star that feels like some kind of variable thing so I'll put it at the top and then I can say atroot fu goes to fily caddy file

David Busby: Then what do I do? System. Take it.

david raistrick: Do you have to reload it?

david raistrick: I don't remember if you have to reload or if it dynamically does it. Mine was all buried in Docker, so it was constantly restarted. So, I don't remember.

David Busby: I have to reload it.

david raistrick: Does it? Okay. Yeah.

David Busby: Here's demo working just like we want. Flashfu gives me a 404. Slashfoo slash doesn't give me what I want. slashbooindex also says ht. It gives me a4.

david raistrick: So for mine they all have handle blocks and where you just have at food defining the handle there's actually a handle block for at fu. So at user home or handle actually though I guess remote my reverse proxies are similar to that.

david raistrick: they're just defined with a block. because that handle is your definition of you it's effectively like an alias to say when I drop this into a config it does these things

David Busby: Yeah, this one that so I asked it about as GBT what the hell's handle route or handle something. I said don't I need handle blocks? So, pro tip there, right? Let's go back into this stupid thing and get rid of the at fu and say now this feels naturalish to me where I'm putting my more strict path first and…

00:15:00

david raistrick: Yeah. …

David Busby: then it says Really?

david raistrick: all the more strict paths are after. So, I don't know if it matters. Yeah. Yeah.

David Busby: And then in these handle blocks you have to say file server for both. …

david raistrick: Because one of mine I have browse turned on so that you get directory browsing. There's file server browse and…

David Busby: auto index. How did you do that?

david raistrick: and that it's just file server browse and…

david raistrick: then I have some additional extensions to hide dot files from it.

david raistrick: I forget why I did this, but I have a reason server space browse.

David Busby: you just say files. So that's add something plus options something in the Apache universe. so this feels like it should work like we intended. Reload that bad boy. hey there's my foo index file just like I wanted. And then temp doesn't work because I actually don't have that path here. So let's make one called temp root and then let's touch a thing called a.ext and b.ext and see what we get. I was expecting to get an auto index.

David Busby: So if you just say slashtemp, I don't get it. But if I say slash some Yeah,…

david raistrick: It needs the star.

david raistrick: Does it just need the slash? Yeah, it just needs a slash,…

David Busby: then it treats it right.

david raistrick: which means that you need something different in your expression,…

David Busby: That's nice.

david raistrick: right? config up So the ones that I have like that instead of temp slashstar it's tempar.

David Busby: I think I wouldn't say my handle path is slashfustar. It would

David Busby: But it still points to a full path here. The root.

david raistrick: Yeah. No.

David Busby: Do you need …

david raistrick: No. Because the ones I have are reverse proxies on the other end of it. But I think it The pattern matcher is requiring the slash. you could make instead you can make a cat to the splash.

David Busby:

David Busby: When I take that slash out. So now…

David Busby: if it's setting temp and then it's automatically adding the trailing slash when I go there.

david raistrick: Downside is it probably would match temp anything,…

david raistrick: right? Because it says,…

David Busby: But now if I temp 3,…

david raistrick: I'm giving you a directory,…

David Busby: it says 404,…

david raistrick: right?" Okay.

David Busby: which I guess is what I expect because there's no 404 file in there or there's no file name three.

david raistrick: And there's Yeah.

David Busby: If I wanted one of the files in there,…

David Busby: I'd have to add the slash and then say a.ext, which it delivers, but temp a.ext. Hey, look at that. Even if I take that slash out, it's still serving that file. So, I don't think that's good.

david raistrick: Yeah. Interesting.

David Busby: I want that slash to be

david raistrick: There's probably some quirks in it somewhere that,…

david raistrick: I wonder if the star in the root or if there's just a better way to catch. I think Can you give it a list? So you could give it temp slash and temp slashstar or slashtemp because you're wanting to catch slashtemp, So either another handle path or maybe it can take two paths on the command line on the config line. I mean I'm just doing that without looking at documentation.

david raistrick: So, I should probably look at documentation.

David Busby: f*** the documentation,…

David Busby: It's supposed to be intuitive.

david raistrick: That's never the case. Come on.

David Busby: So if you go and look at handle only a single path matcher is accepted. You cannot use named matchers. This configuration is effectively the same as something is slightly more succinct. okay. I see.

david raistrick: There's a red redirect in

David Busby: Be aware of this thing that they call What is the subfolder problem? So, I was on handle path nice looking Always hand good. Well done. But it tells me you can only do a single path. So your intuition was wrong. and then the subfolder is you have something for another self-hosted for radar and son. okay.

00:20:00

david raistrick: where they took son to SLS sonar slash or whatever it was in that example.

David Busby: That's cool because that was one of the next things I wanted to sort of look at was redirect because you've got to do some redirects. I guess they call it reader matcher 2 code. So then I would say handle path slashtemp slashstar but maybe before I'd say the subfolder problem reader yeah right before their handle path they said configuration…

david raistrick: Look, what was that example that had the sonar in it that you were scrolling down past a minute ago? Yeah. Go back to the top of that because there was an example right there that's showing Okay. Yeah. It's outside of the handle path. Yeah. Yeah.

David Busby: but disaster strikes and you get a poorly formatted page. maybe something. This isn't unique. Every single reverse proxy you care to name inherent problem under an assumption there ser something proxy doesn't know the path.

David Busby: This one says this is sort of different than the problem we're having. because they're also including a reverse proxy and at this point we don't have a reverse proxy. We just have a thing where this slashtemp directory.

david raistrick: I mean functionally it is a reverse proxy.

david raistrick: But you're right. You're not using the reverse proxy directive. So, you haven't hit that challenge. I think that Yeah. Yeah.

David Busby:

David Busby: I think this is what I would want to do. redirect temp and I'm wondering on reader it says it's a matcher matcher syntax is like a star this isn't like really it's not a reax or…

david raistrick: star path or…

David Busby: it's like a glob pattern only temporary

david raistrick: right I mean I think it's specifically star or a handler named the atnamed handler or…

david raistrick: whatever that is or a redirected slash.

David Busby: That's what I think I want it to do.

David Busby: Reload caddy. And so now if I go to slashtemp,…

david raistrick: Yeah. Yeah.

David Busby: it says location is lash. So then I end up going to slashtemp slash.

david raistrick: It's funny. we always assume that to work,…

David Busby: I get a big thing.

david raistrick: but that was just a default config in Apache that we all assumed would work.

David Busby: So now my request to this one that looks stupid,…

david raistrick: We just used to Yeah.

David Busby: temp a should give me exactly what we wanted, the 404. Putting the slash in properly, it works. Going here, I get this and it bounces me. So that's what I wanted for both of those. And it feels like I should make the same kind of rule set for my silly foo path and…

david raistrick: Right.

David Busby: "Okay, if you just say foo, then you actually want foo slash." It doesn't really seem too terrible since now I understand how these patterns are used. So that's great. So then in web routt we want to do And I mean, since we're having so much fun with this Whoops. Since we're having so much fun with these directory things, we'll make another one we'll just make it go into the PHP path. Why not? And we'll call that one something clever like PHP route as I'm so clever.

David Busby: index.php is what you usually call it. so then what happens if I go to slashphp slash and…

David Busby: it tells me a 404. So now we want to do the how do you enable PHP?

david raistrick: …

david raistrick: and that's where it doesn't do it natively, So, you're going to either use fast CGI or…

david raistrick: you're going to proxy to something running PHP. Yep.

David Busby: encode dj.

David Busby: So it tells me I have this directive I can use called PHP fast CGI and here I already had that one open and so you just give it a bunch of stuff there are the addresses of fast CGI servers. I think that exists already on this machine. FC CGI. what? Really? Am I stupid?

00:25:00

David Busby: feel like I'm this in some kind of terribly stupid way.

david raistrick: Yeah, that makes sense because

David Busby: Yeah, I'm a dumbass. It's You are seeing this because something need to in Apache. this is all just noise it's making. You are seeing this message because you have Apache 2 installed. I do. All right.

David Busby: PHP FPM is running. That was it. I just had to install that. I forgot. Wrong search term. And then they seems like they have a lot that they've written in there. And then this person just writes the word in their root just says fast CGI Unix.

David Busby: Just says whackwack. I feel like it should say Unix colon.

david raistrick: I know I feel like should have a colon in there,…

david raistrick: but it does not have the colon in it. It is just Unix slrun for the socket path.

David Busby: I think your problem is with your tri files.

David Busby: Come on.

david raistrick: Yeah, there it is.

David Busby: I don't believe you. s***, there it is. Listen, I know,…

david raistrick: I mean, this is just connecting to the filebased socket,…

David Busby: but something.

david raistrick: but right, I know we're used to seeing it as a Unix colon slash, but it's not

David Busby: All So, I had file server enabled and…

David Busby: then I'll just say this, but that's not the same socket. This one's old.

david raistrick: So I think that has to be outside.

david raistrick: So what you would do is you would remove the file server from it and outside of the handle directive you reference it with its little at alias or…

David Busby: Say that again.

david raistrick: whatever. So where you have it currently inside instead so your handle path your handle I believe that it has to reference it through either star or at something right which you haven't used any in this yet but I believe you have to reference it for reverse proxy and fast CGI and those types of config you have to reference it so you create a handle

david raistrick: with basically it's a named handle.

david raistrick: I don't know what the hell they call it. that uses at label. Probably look at the documentation.

David Busby: This example right here just says handle path fu,…

David Busby: And it just says I can throw fast CGI in this.

david raistrick: It does. Okay. maybe you can. I've only seen them where it's outside and referencing it through the alias, but let's do it.

David Busby: I wonder why they put it before That's a chance I'm willing to take.

david raistrick: It might conflict with file server though.

David Busby: So now we're trying to go to PHP and this first one we should see a redirect location/php. That's fantastic. So then we get slash xdebug profile cache grind out. That's awesome…

david raistrick: It's positive.

David Busby: because that means it's done something. The file's content length zero is…

David Busby:

david raistrick: You redirected it to null,…

david raistrick: didn't you?

David Busby: how I saw that.

david raistrick: Yeah. yeah. You're right.

David Busby: But that's because in root index.php is empty. We'll do the classic barfing out PHP info. Run it again. I got legit on the page. Exactly what I expected. I'm going to turn off XD debug because we don't need to see that s*** right now. and then what happens if you go to root index.html. Wonder if it serves that. Nope. It prefers index.php. that was where this other fell I saw. That's exactly what we wanted. Barfing out my older version of PHP. Where'd he go? Caddy biopathing.

00:30:00

David Busby: So on this one saw this other person having try files and it says html to index.php and I'm wondering why you would want to do A pattern that I see pretty frequently is…

David Busby: where you will have a configuration in Apache or engine X that HTML first if it exists and then if it doesn't tries de I've written it in there you have to say directory index and…

david raistrick: I think that was again coming from Apache defaults though,…

david raistrick: So that's what everybody got used to…

David Busby: then you give it a list of file names order index.html…

david raistrick: but there was a default for that. So if we didn't specify it it would fall back on default. Yeah. so people…

David Busby: if you don't say anything it's out of the box it's just index.html Yeah.

david raistrick: who might be expecting it to take an index.html primarily might have learned that in the Apache days.

david raistrick: So they look for that,…

David Busby: I mean this one is…

david raistrick: right? the same reason we look for The slash to slash redirect to work.

David Busby: if the requested file does not exist try index files and then assume PP always exists. First exist fall back split path PHP. This seems sort of complicated. This is the expanded form of this directive. …

David Busby:

david raistrick: basically you need something complicated.

David Busby: you can say here's an override for the try files directive for build. The default is try try the path with index.php. then just try regular ass index.php.

david raistrick: Yeah, you added in the directive.

David Busby: And so I wonder if you can just take that and dick about with your caddy config. how do you do this? Fast CGI and then I do a curly bracket and add this s* in there. All right. Fast CGI Curly bracket. my new nonsense and what was my new nonsense Try files. I recognize that name. So then I would just try path and then path index.php. And then I think this index php means if it doesn't find it, it's going to just try the one in the site route, which seems not like what I want.

David Busby: But I bet I know why it's their out of the box default is because lots of tools like Joomla and…

David Busby: Drupal and WordPress and various other framework tools on the Apache universe. You set it up to just rewrite and you use some other config

david raistrick: Yeah, it's using one file.

david raistrick: It's just saying what URL am I being requested by?

david raistrick: I'll return you the thing from that. Yeah. Yeah.

David Busby: So you can get pretty URLs and…

David Busby: they have a whole shedload of routers that are in that thing. Larville and Yei and Cake and Zen these other frameworks like to do that stuff out of the box. So we'll do an experiment there because we have path in. So now it's going to be looking for the whatever then path ml then the PHP one in path. Then it's going to look I think we are assuming that those last two are the site rooted index html and index.php. Let's just find out real quick. so then I have to go to PHP root and we'll make another thing in here that's called just p test. How about something clever like that?

David Busby: Whoops. we'll use that. That's a good example. So, if I go to just PHP, I get that redirect. And then if I go to slashphp like we're wanting, I get root index.html. Found my root index html.

00:35:00

David Busby: but if I can still request index.php and get all this stuff, that's expected behavior. and then what was the directory I just made? path dash test. Get that by itself and it says you need to have a trailing slash. That's fantastic. Then I get it by itself and it gives me index html. That's what I expected it to do. because we're saying look for index html first. So then if we go into path test and remove index html what is it fetch? It gives me index.php. That's what's expected. Now I'll just remove that index.php and what do I get from path test? Now I'm getting root index html. I'll just turn verbose off.

David Busby: And so that's because now we know path test it doesn't have anything.

David Busby: And so it's routed me back to here. And from our caddy says we're doing this this…

david raistrick: I mean that's pretty much exactly…

david raistrick: what Yeah.

David Busby:

David Busby: And so, I'm going to change the universe and then say, I'll make a file here called main.php, which will be the entry point. So, then if we go to path test and put another PHP file in here again. path test now should give me its index.php. That's awesome.

David Busby: path test blah blah blah blah blah gives me the site root index html. because some idiot didn't reload as caddy. So, this should now route into a file that doesn't exist. That's perfect. that file is main.php. print job. So if we hit that path now basically now that last file in try files because it doesn't include curly path it becomes my final landing point in my rewrite rule or…

david raistrick: Yep.

David Busby: if you rigged it up as my 404 handler is this final file and it gives you a bunch of stuff in the server variable like you would expect. So all that stuff shows up in your Django and your Rails and all of your other stuff like this. I mean except minus PHP self and stuff like this. So there's another funny trick those folks do with this path info component of PHP and that allows it to send it something like index.phplah PHP blah blah blah and…

David Busby: it behaves, you can see this extended path. This should probably be giving a 404, but that extended path info.

david raistrick: I mean,…

david raistrick: it's basically using slash like you would use a query parameter.

David Busby: When one of these things in your path is a file that actually exists and then you can see in the spew. It'll probably be easier to see it from the console path info becomes this s*** that's been appended to and then they give you this translated thing. It would be something like this. It's basically saying you requested a file that we know exists, but then you have some extra s*** afterwards that looks pathy.

David Busby: Forget about it." is what it's do. That's a trick that some of the other ones use, Jumla didn't do that. Jumla sent all of your requests to index.php.

00:40:00

david raistrick: It's partly…

david raistrick: because query parameters get excluded in a lot of tooling for a long time and probably still, A lot of analytics tooling would exclude query parameters. So by using slash for your query parameters that meant that you had got explicitly treated also SEO because index.php question mark bunch of things is only one page whereas index php slash are all different pages. So your single page app actually is many different pages to tooling.

David Busby: A man that whole, your URL with all those question marks after it being a part of SEO nonsense,…

David Busby: man, that's got to be over. It's 20

david raistrick: I don't know.

david raistrick: I mean, but these are the reasons they got this existed, it used to be the way,…

david raistrick: so therefore the tools exist. What it is today, I don't know. Yes. I mean,…

David Busby: The momentum problem.

David Busby: Okay.

david raistrick: you built an application in 2003 or 2005 and it's still running today. Are you going to revisit the design of how your URLs are structured? No. I mean, you did, but you probably did it about 2011.

David Busby: Maybe in 2025. Why even bother to write fancy routers for the stuff since all the things you're putting together is maybe it's just some API thing,…

David Busby: route all the stuff using the way Air quotes nature intended, with a path and then all the other things are actually in the query parameter like they're supposed to be. I'm doing a bunch feels like a bit of a religious war.

david raistrick: or they're even post parameters,…

david raistrick: They're not even Yeah.

David Busby: Should it be a query string parameter, or do I go to slash company slash some database identifier or something or do I go to slash company question mark ID equals some nonsense, and the spec gave us question mark ID and you're like, I want to have a friendly URL, so I want company slash some other action. And you get to spend a bunch of time working on routing rules in your application. But I think that's probably the last fancy thing to talk about here is routing something.

David Busby: And I think that's the command that is called rewrite rule. This one says you can do a No, sorry that's the wrong thing. Rewrite rule.

david raistrick: Sort of…

david raistrick: because you're already routing, right? You're some things, right? So,…

david raistrick: you're taking that path prefix and routing it to P PHP. You can take that path prefix and route it to a reverse proxy to go to another application, too. And it's just the same style directives. Yep.

David Busby: Yeah, that's… what I'm talking about. we've got something slashphp we did just to have the location to test with PHP scripts which is nice because now our other directories one of the finger waggy things that caused some danger for the PHP universe was if you had folks upload malicious files into some spot that was then also web executable if this configuration here in this config here, we'd have these scripts running under slash CGI-bin. I'm sorry.

David Busby:

David Busby: I mean, PHP and then they upload tools or all of their uploads get written file systemwise perhaps into this other web route handle that is slashtemp which now is just having the static file server with browse enabled. and that's like a nice little thing or something. But the rewrite, I think, would allow you to do something else perhaps. And maybe the rewrite has to go first or last. But I'm thinking that rewrite is going to be something like I want to rewrite something like company slashnonsense into slash company.

david raistrick: So you wanted to rewrite slashhome, So if you wanted to implement the theome tilda or public html type of setup, right? You would end up with rewrite rules for that.

david raistrick: I believe it ends up having to go into a handle directive.

David Busby: This…

David Busby: if you can see what I wrote there. I wrote I said I want to make it so using that crappy API example. In fact, I'll make it even more obvious. I want to rewrite the request slash API company slash some value and I want to rewrite it so that it's handled by my slashphp handler.

00:45:00

david raistrick: You can do it directly.

David Busby: I think that's going to do it.

david raistrick: Yeah. I'm not sure I don't know if that matches the pattern matcher or not, but yeah.

David Busby: Listen, what's not like it's going to catch on fire?

david raistrick: Yeah. I think you'd end up with a star and…

David Busby: Reload didn't s*** the bed the web server.

david raistrick: then you extract pieces of it on the right side of it.

David Busby: But now I should be able to go to API company something that gives me a 404.

David Busby: Sure something. And then one, two, three, four. My favorite company. So that gives me a 404 reason.

david raistrick: There's a fail on your reload.

David Busby: No, there's not.

david raistrick: That's not that connector post isn't from that.

David Busby: No. In fact, I thought I disabled this.

david raistrick: Is that where it's coming from?

David Busby: And now it's trying to do something. wait a second, Where's all my directories in log spew? I feel like I should have a bunch of spew in here.

David Busby:

david raistrick: But I believe you're in a system D world.

david raistrick: Aren't you in a systemd world though?

David Busby: Yeah. man,…

david raistrick: Are they all under journal D or whatever? I can't remember.

David Busby: I don't know. How would I look at that?

david raistrick: I don't remember how logs work. I will never remember how system D logs work.

David Busby: This thing says you have to do some log direc directive. Maybe it's going to standard out.

David Busby: It looks like this is complicated. I didn't want that to happen. I wanted to have logging out of the box. But maybe that is Here's the guy…

David Busby: who told me how to remember it, I don't. so now I have this log and told me it reloaded Caddy. So that's cool, but it's not giving me access logs and stuff in there.

david raistrick: Yeah. No,…

david raistrick: because this is just your application plugs.

david raistrick: You'd have to turn on your access logs. You could probably send them to standard out and all, but

David Busby: Dang, man.

David Busby: Let's see if the knows how to do the thing.

david raistrick: Yeah.

David Busby: A network error occurred. everybody's having problems on the internet today, We use this tool called Uptime one of those monitoring thingies. And it was not running this morning. and then their sign in wasn't working and stuff like this which sucks for them…

David Busby: but at the same time I makes me feel sort of like look I'm not trash I wonder if this file is whites space sensitive what's happening on that server on port 2019.

david raistrick: I don't think it is.

David Busby: Do you know?

david raistrick: Don't know.

David Busby: what did I say it was? API company 234 content link. I'm getting a 404. I'm also confounded why I keep getting these PHP debug issues. I know why.

00:50:00

David Busby: Okay. I think that gave me logging though. Yeah, it did. Looks like it's a little JSON blob that it writes.

david raistrick: Yeah. Yeah.

David Busby: That's pretty cool.

david raistrick: And you can turn on common logs or other formats, but everybody likes JSON these days for arguably good reasons if you're ingesting them into other tools. If you…

David Busby:

David Busby: No, no, no, no, We should parse.

david raistrick: if you want a common log, you can turn that on.

David Busby: We should arcanely delimited text with custom every time.

david raistrick: Wealth? Wasn't that the standard for a long time?

David Busby: I do not recall. yeah. Here's the thing with those rewrite.

David Busby: I wanted to remove rewrite. and you put some curly bracket in there.

david raistrick: The web trends log file.

david raistrick: Yeah, that was it. Web trends enhanced log file.

David Busby: So this person is redirecting well known to somewhere but this one is trying to rewrite something to this guy's trying to take paths and…

david raistrick: Yep.

David Busby: turn them into query string or it looks like pico CMS but I'm trying to get rewrite to a new URL,…

David Busby: Isn't that it? Just rewrite something to a new Wait a second. Let's just Yes.

david raistrick: Because you were trying to particularly take the company ID,…

david raistrick: it sounded like you were wanting to take the company ID and pass it along, So, if you just wanted company star I'll be right back.

David Busby: Trying to send it into company.php, which doesn't exist. sure.

David Busby: And so that didn't do…

David Busby: what I wanted it to do either. I thought So I went to look at my caddy config here and in this caddy config I didn't have a file that was called company.php.

david raistrick: I think it's for ID.

david raistrick: That's fair. Yeah, I don't think that matcher is valid in their syntax,…

David Busby: So I said rewrite company. I guess maybe my match is So if I just say company slash star and…

david raistrick: I think there's more advanced stuff that can be done,…

David Busby: so when they say matcher they mean glob pattern.

david raistrick: but I don't think it's in

david raistrick: Let's see.

David Busby: Yeah, that's what it was. change the path in the query string preserving.

david raistrick: Yeah. Yeah.

David Busby: So in the rewrite, I'm looking at these things here, but in the rewrite you can take the other things that you were handed and put them at the end.

david raistrick: And I think you can get somewhat complicated with that. good if you do path reax then you can get more and so then you can do reax extractions and…

david raistrick: pass those through and do redirects or rewrites using those reax pieces.

David Busby: Yeah,…

David Busby: I'm out. But anyways, that serves up everything that I was thinking about getting it to do. No problemmo. Turned out to be very, very easy. there was a little bit of that fiddling with this redirect with the trailing slash, but that got sorted. I don't know the order of these rewrite rules, but I typically put them near the end. Typically, I put the logging stuff first. But then if you wanted to have rewrite rules in something like this, you would end up having a company rule and…

David Busby: then I don't know how you would get to company slashupdate, it seems like this pattern matcher is really the whole rest of path.

00:55:00

david raistrick: Your company.php would be looking at your path that was sent,…

david raistrick: right? Yeah.

David Busby: What else do you have in the system? You have a company and you have a contact. And then those two scripts would then have to do their own sort of path parsing to my path for its regulars runs against the

david raistrick: If you wanted to parse it here, you would use ax. Yeah, xp path_ regge exp and you can do the path extraction using this, but it's a lot easier to codify that inside your language since you have a language available to you.

David Busby: match request for something and something. how do you use that?

david raistrick: So the way I use it is in the alias. So let's see I can send you an example. I don't have a good way to send you an example.

David Busby: Paste it in the meeting chat or something. you would have to set this up as some kind of variable name that…

david raistrick: Let's see here. Yeah.

David Busby: then gets matched to later or something instead of just you have to do a path reax for here's something and so you make that directive first. Yeah, I see what you're talking about. You would have to make something along the lines of,…

David Busby: at name path reax reg x and then you do some stuff and then way later you write handle at name.

david raistrick: Yeah, because I'm referencing that alias and…

David Busby: It looks like it's slash name path x reax name and…

david raistrick: then I'm using re the reax

David Busby: then something and then you say I'm going to say this is dollar varss to help me think about it but then you say handle at name that you defined and then in there you can use a reader and you can use dollarvars one2 it looks like from your match or…

david raistrick: Yeah. I don't…

David Busby: something. this is obviously incomplete. Then I'm not going to get there. But that means if that shows how it's possible if you wanted to do something. Wonder if these are the comment characters.

david raistrick: if it does those. I know it does hashes. I don't know if it does

David Busby: But that could be the way that you wouldn't just rewrite company this company You would have a path reax for your complicated API URL that would then match against API slash list of object names that I accept regular expression that matches…

David Busby: what my ids should look like slash optional sub action

david raistrick: That said,…

david raistrick: that said, it's so much easier to just redirect your path into your code,…

david raistrick: let your code handle all of that extraction and management in one place. This was great when we were doing it for static files on a file system.

David Busby: I mean,…

David Busby: I'm with you,…

David Busby: but if you have the rewrites in here, it allows you to not have them in your code. I mean,…

david raistrick: It does let you exclude things from your code so that your code doesn't have to do that processing. Absolutely.

David Busby: I think there's a balance on either one of those, it's just like send it into the thing and the code can make some very reasonable assumptions about the universe. assumptions that we think are reasonable about the universe and…

David Busby: sort of just like if I have this thing or s*** the bed, you know what I mean?

david raistrick: I think that right and…

david raistrick: I think that there's the challenge I've often seen there is finding that balance between code that doesn't know enough.

David Busby: Yeah, your config didn't somewhere

david raistrick: So if you find a path that gets you to the code, then the code didn't exclude something it should have excluded. and so you've got it in two places. The reason we put it up here is as a filter, but all the rules should be in the code to prevent it from doing something it shouldn't do because we may fail in our filters or we may have accidentally turned it on without those filters yet, right? We've turned this application up for the first time.

david raistrick: We're still building and figuring out what we need to Make sure your code understands that it should only do…

01:00:00

david raistrick: what it's only supposed to do. Never assume that its inputs are valid. And yeah, there's no block comment. It's Just hashes pounds. Yeah.

David Busby: I agree with that.

David Busby: Just pounds. Dang, that is unfortunate for me. anyways, this worked out exactly like I wanted it to, much faster than I thought it was going to sitting down to learn another tool, something like this is generally,…

david raistrick: Right.

David Busby: it can be a bit of a struggle, and It was one of those things about nice opinionated tools too. They show up and they do a bunch of stuff sort of like one expects them to the try files default and example that they provided gets me what I wanted to get and was one of those things that I would sometimes have to struggle to dial in Apache or Engine X with multiple lines of config. no thinking for the SSL was pretty dang amazing. and he's like, " here's how to make a static server." I wrote redirect to do it for slashfu, but there's no reason that this wouldn't be like your slash CSS or your slashjs or image or video directory or, where you're talking about reverse proxies or something like this.

David Busby: Maybe next time we could dump this thing out and it reverse proxies but also offers some caching to some static assets on the back end. I mean something else to dig on, I don't know if I'd want to do that for video files or something like that, but for a couple of static text assets that it gzips, which it looks like I have to enable that manually, too. no big deal. And then keeping the log inside of my server context. I think that's pretty cool because you can then make your log file always be to include the host name. I wonder…

David Busby: if I can get a variable in there. I notice they have some Could I do curly braces host or Something to find out later.

david raistrick: Yeah, there is sort of some ways to do it at your confi manage your logging at a global level,…

david raistrick: but it is kind of awkward. it's really designed to be to manage your I have a directive called logging that sets up access logs and stuff like that and then I import that into each of them.

david raistrick: So, it's sort of possible, but It's still managed really per site.

David Busby: Yeah, this is pretty cool.

David Busby: Then the general options turn on some debugging. You can put logging at the top level auto https with various mechanisms. I guess I didn't even have to put my own email in there for the acme blah blah blah. That's cool. this is cool.

david raistrick: Yeah, it's interesting. I think I only have it set up for the staging CA. Maybe that's where I have my email. I don't know. Yeah. Go,…

David Busby: Good times. all right.

david raistrick: Yeah.

David Busby: That's a wrap. I thought that went incredibly well. Recording off. I have the transcript still going, but I thought that went incredibly well.

David Busby: It worked out Dropped this one out. that was awesome. I know we had some other stuff on the list, but kind of digging into the guts or showing something off. One of the things we can do to build noise machines for ourselves is attach our s*** to somebody else's s***.

david raistrick: right? Yeah.

David Busby: Do you I mean, and so that's exactly what this was intended to be. Awesome.

david raistrick: Awesome. …

David Busby: Maybe I'll see you tomorrow.

david raistrick: let's see. What's tomorrow? No, I got an appointment tomorrow.

David Busby: Open coffee.

david raistrick: So, yeah, my Tuesdays are hard.

David Busby: All then I will hope to see you on Wednesday.

david raistrick: right, man. Bye.

David Busby:

David Busby: Cool. Thanks. That's

Meeting ended after 01:04:49 👋

This editable transcript was computer generated and might contain errors. People can also change the text after it was created.

AI Created Summary

Alright, here's the transcript turned into an article, adopting the royal "we" perspective:

Diving Deep with Caddy: A Journey into Modern Web Serving

In a recent session, we embarked on an exploration of Caddy, a modern web server that has been generating quite a buzz. Our mission was to thoroughly test Caddy's capabilities, with a focus on its ease of use, PHP integration, and routing prowess. We aimed to discover if Caddy could truly simplify the often-complex world of web server configuration.

Initial Setup and the Magic of HTTPS

We began by installing Caddy on our demo box, and right from the start, we were struck by its simplicity. The installation process was remarkably smooth, and we were soon faced with the server up and running. However, the real magic happened when we witnessed Caddy's automatic HTTPS in action. Gone were the tedious days of manually configuring SSL certificates; Caddy handled it all seamlessly. This feature alone significantly streamlines the setup process, saving valuable time and effort.

Routing and Directives: A Deep Dive

Next, we delved into Caddy's routing capabilities. We experimented with various directives, such as handle_path, file_server, and try_files, to control how Caddy processes requests and serves files. We successfully set up redirects, enabling clean and user-friendly URLs. Integrating PHP was also a key focus, and we were able to configure Caddy to work smoothly with PHP-FPM.

We did encounter a few interesting quirks along the way. For instance, we had to carefully consider the order and syntax of directives to achieve the desired routing behavior. We also explored the intricacies of serving index files and how Caddy's try_files directive offers powerful customization.

Reverse Proxying and Logging

Time permitting, we briefly touched on reverse proxying and logging. We discussed Caddy's potential for acting as a reverse proxy to other applications, and the benefits of centralizing logging within the server context. While we didn't delve deeply into these areas during this session, it's clear that Caddy offers a comprehensive suite of features for modern web deployments.

Our Verdict: Caddy Delivers

Overall, we were thoroughly impressed with Caddy. It proved to be a powerful and versatile web server that simplifies many common tasks. The automatic HTTPS, intuitive configuration, and flexible directives make it an excellent choice for projects of all sizes. While there's always a learning curve when adopting a new tool, Caddy's opinionated approach and excellent documentation significantly ease the transition. We believe Caddy has earned its place as a serious contender in the web server landscape, and we look forward to exploring its advanced features in future sessions.