Syntax Video
Self Host 101 | Office Hours LIVE | Reviewing Your Questions and Comments
- 0:00 Stream Starts
- 2:00 What are Office Hours?
- 2:29 HTTP and HTTPS Default Ports
- 5:13 Responding to Chat
- 10:19 Using CNAMES for Subdomains
- 14:39 Responding to Chat
- 19:04 Cloudflare Proxy / DDOS Protection
- 29:59 A vs AAAA vs CNAME Records
- 32:01 Responding to Chat
- 43:32 Let's Encrypt and Certificate Authorities
- 45:55 Responding to Chat
- 49:35 pm2 Web Dashboards and Monitoring
- 54:11 Home Lab Hardware
- 55:55 Responding to Chat
- 59:00 CI/CD on a VPS
- 1:11:50 Running Docker on a VPS
- 1:35:39 Create Caddy reverse_proxy to a docker container
- 1:46:49 Docker automatic reverse_proxy with Caddy
- 1:49:22 Self Host Email Server
- 1:53:58 Manage Caddyfiles with a single folder
- 2:01:01 Suggestions for Next Time
- 2:01:49 Preview Deployments with Coolify
- 2:02:43 What do you want to see hosted with Coolify?
- 2:04:08 Coolify Build Server
- 2:06:33 Brought to you by Sentry
- 2:10:00 Thanks!
Stream Starts
hello everyone welcome in uh welcome to self-host 101 office hours live so we are currently live on uh twitch and YouTube and also Tik Tok so if you're watching live say hello in the chat let us know where you're watching from uh this is the first live stream I'm doing here on the syntax channel so I'm super excited and uh the plan for today is uh I have to juggle a bunch of things so that's why I'm looking over this way but the plan for today is to cover all of the questions and comments that showed up in the last office hours video um so there are quite a few good questions I've got some resources for you and I'll show show you some demos as well once we get into it uh we are answering questions and comments from All of These Fine people as well so if you're in this list and you're watching live let us know but yeah I'm going to check in the chat make sure everything's good make sure people are here can you hear me okay let me know yeah and the the intro music is awesome uh Scott made that so definitely check out that link
am I am I loud and clear nice nice nice nice nice there's probably like a little bit of delay uh once I know that you all can hear me you can see me we we have like two two scenes to work with sounds great okay we've got overview scene and we've got uh this scene here that has the uh screen in my face here loud and clear awesome uh so yeah but welcome in everyone uh uh wanis salom is is tuning in from the Netherlands that's great we're actually answering uh two of their questions today uh hako can hear me welcome in welcome gexi and Demetrios uh and Stony welcome welcome to the syntax side Stony has been watching um coding Garden my other channel for a very long time and uh twitch ve tur welcome in welcome in and be mind also a coding Garden fan welcome in everyone and Pao P's here what's up poo it's good to see all your all your faces in the chat and waa gangster
watching over on Tik Tok good to see you uh let's get into it let's get into it so the way this is going to work is I have a bunch of stuff prepared so I'm going to go through these questions and comments for each one I'm going to do my best to answer it also show you some resources and then when I'm done I'll pop back over to the comments and see if you have any extra questions beyond what I covered so um that's the plan so for while I'm while I'm answering the questions I'm not going to see what see the chat I'm just going to be doing my best to answer these questions uh but I will go back to the chat but let's J let's Jump Right In so the first question comes from Alexander rosi and the question is uh thanks for the tutorial but I followed every step got name cheep domain and then did Cloud FL DNS setup and I can't get access to the server via the domain is there an extra step missing so if you are unfamiliar with the questions we answering they're coming from this video so this is a video I posted last week about setting up caddy on your own VPS and um so all the questions I'm answering are from this video and this
What are Office Hours?
HTTP and HTTPS Default Ports
first question uh I do believe that Alexander actually figured it out they they mentioned in the comments that they got it working but the issue was they didn't have all the right ports open and this is probably my fault I think I hinted at the fact that you need both Port 80 for HTTP and Port 443 for https to be open but I kind of glossed over the fact that you need Port 443 to be open and that was their main issue they uh had everything working with their domain DNS was working but whenever they set up https with caddy the site wouldn't load and that's because https runs over Port 443 that's the default Port uh and you may not realize this but when you go to a website and it's https your browser is actually uh typing in uh well not typing in but it's it's sending across that Port by default 443 so if I try to connect to the site and actually put in 443 you'll see the browser just uh removes it because that's the default port for https and same thing for HTTP uh Wikipedia has an HTTP redirect but if
you try to go to the site and then specify the port as Port 80 um that will redirect and you actually don't see the port so by default all this web browsing that we're doing is happening on Port 80 it's happening on Port 443 so any web server that you set up you're absolutely going to need Port 80 and Port 443 open and then Bey that you probably might also want to have uh your SSH Port open which is typically Port 22 if you give me just a second I need to uh change a browser setting but I will be right
oh hey I forgot that I had this scene on you can't see it on Tik Tok but if you're watching on Twitch or YouTube you can see my whole studio I forgot that I had this be right back scene
cool all right we're back cool so yeah thank you very much Alexander for your question um ultimately ports are very important so if you're serving httv traic you need Port 80 if you're serving htps you need Port 443 open so any any questions or comments so far on what we talked about let's see and Liam good to see you welcome in uh can we do a live Q&A voice chat I don't have that set up but that would actually be very fun to do in the future we and especially if we can get some like Discord engagement it would be fun to get some uh some of some like a voice channel in the Discord and then I could um you all could phone in and ask questions that would be fun but it I have so much time juggling on my streaming computer I don't think we can do it today um yeah and so poo says uh I spent a bunch of time dealing with my VPS with kify and cloudflare was getting a bunch of Misses in the end I was always connecting to a different data center oh no oh no uh is it a bad idea to have your database in a VPS we were actually going to talk about this later so
Responding to Chat
there's a question that popped up uh about being able to host databases on your VPS I wouldn't say it's a bad idea but there's a lot you need to take into account things like backups uh uh replication it's not it's not that easy I mean technically if your if your site isn't that big and you don't have a lot of users you could host a database but there is a lot you need to think about so we'll cover on we'll cover that in a little bit Yeah and definitely check out the Discord um because lots of lots of fun people over there uh Su James says would you advise hosting UI server NDB in the same VPS for an that pays it's all going to depend on the amount of users that you have the amount of traffic that your site has because and also the size of the VPS that you're hosting it on because it is possible but part of a more scalable architecture is you separate those things like you you potentially host your static UI on a CDN so it can be it can load really fast and be replicated across the the world you potentially have multiple servers behind
a load balancer you have like a replica set of your DB so like there's there's ways to scale this stuff that you potentially need to think about depending on your the size of your app and how many users you have but I will say in my professional career I have hosted um the database well actually no most of what I've done in in my career the the database is almost always on something like AWS RDS because they handle the backups they handle all of the stuff for the important data so we're willing to pay that price for AWS RDS but for like UI server and API server I've run those on a single VPS for an app that has maybe a few hundred users so it really depends on your use case uh twitch vur says should one use caty reverse proxy When developing or just use ports it's completely up to you I know a lot of people use caddy in development um so that way makes it easier to do like https and stuff like that yeah and Jake says I've been dabbling with running llms locally you think it would be cheaper to host an lmm
llm on a VPS or use the open AI API we're getting off track but it's it's fine because I enjoy answering your questions LMS typically require a GPU and it can get very expensive so if you look into vpss that have a GPU attached to them they are much more expensive than like a $5 VPS a lot of times it starts at like a minimum $100 a month so more often than not just using the AP the open AI API or the Gemini API or any of these other AI apis are probably going to be more cost effective than trying to run stuff on on a server that needs a GPU yeah and can you set up cicd with a VPS we're going to answer that question today so that is coming up let's see do I have any other questions from uh Tik Tok or twitch yeah Stony and Bine they're definitely the twitch the twitch dudes uh but yeah so Bine says I use cap Rover and I love hosting a DB that is only exposed to the other containers that's the thing to consider right so we talked about Security in the first video in the
self-host series so if you don't know what we're talking about go to youtube.com/ syntax FM and uh go to playlists there is specifically is this playlist called self host 101 and so the very first video I show you how to lock down a VPS and one of the parts of locking it down is to lock down your firewall so you only have the ports open that you actually need what that means is if you have other services running on the server like a database you don't have to expose that to the world especially if that API that is accessing that database is running on the server itself so you can have the database running right next to the API and you don't need to expose it to the world there are again there are implications of that because you have to make sure you have backups for your database and everything else but yeah uh how do you store secrets on a VPS um we'll save this one for later remind me if once I uh finish answering questions we'll come back to this because there are some open source projects for they're basically like vaults where you can you can keep your um various keys that you want to
share between Services um but typically these are just stored in in environment variables on the server itself yeah cap Rover versus doku versus kify I trying kify right now uh in the future it would be it would be fun for me to try the others so I can compare and contrast them but so far kifi is one of the first like platform as a service things that I've uh self-hosted platform as a service tools that I've tried I've done most of the stuff this stuff by hand which is kind of what I'm showing in in this series cool thank you for your questions let's keep moving these next questions and comments come from uh carabian the first one is wow what a great video full of content quick question when setting up the DNS records for various websites why not use cames with the at Target and EC Cognito similarly says curious if there is a reason you don't use C name instead of a records for the dubdub duub entries in your DNS great question let's talk about it and let's show uh what they mean so if you watch that video I set up several
Using CNAMES for Subdomains
DNS records and these are all a records pointing directly to these IP addresses but we actually talked about cname records which are pointing to a domain instead of an IP address and because all of these are exactly the same one of the things that you could do is you could for instance set the a record on the root domain right so set it for notloc host.net and then for every other domain that you add create a cname record that points to notloc host.net very similar to how I have this this banana record that points to not local host.net and the benefit of that is now you only have a single spot you need to update if you ever change servers or like your IP address changes or something like that so uh that this is definitely a valid way of going about it the one thing to think about though is whenever DNS lookups are happening that's one more hop that needs to happen for these other domains because once a DNS record resolves to uh a domain like this then we have to query
for that domain to find its IP address so for instance let's let's pull up the terminal and let's just do a dig on uh banana. notloc host.net so if we do a dig banana notloc host.net and we say we want all the C Name Records you're going to see it returns this so any client that is querying for DNS is going to get this result back and it has to do a further query to now get the IP address so now that client would need to do not local host.net a record finally to get the IP address of the server so you are adding one more bit of indirection um but it's it's a completely valid thing to do and then same thing goes for these www records right so in the tutorial we set up a redirect so if you have a website hosted at a subdomain like this when someone goes to www.th subdomain you want to redirect it back to the server and in this scenario it would make a lot of sense to put the uh domain of the root server there so that way because those
two things are definitely linked together you only update them in one spot right so uh and let's just do it so for dubdub dub. bigtim we could actually point it to Big timer and not the IP address let's let's update it so if I change this to a SC name record and I point it to Big timer doot local host.net load TTL and save it now uh when someone goes to www. bigtim it's going to resolve to this then they'll look up the IP address and it will be this and so because these two records are like very closely linked together they're always going to be hosted on the same app that's another scenario where you would um you could link them with a c name like that so um ultimately for the the tutorial I wanted everything to be very clear that we're pointing domains at IP addresses which is why I didn't do the C name stuff but in practice it makes sense especially if you have a lot of domains to manage um I will say one of the things I didn't show in the video but I am going to be showing in the coolify video is what's called a wild
card record so let's say you are spinning up a bunch of apps and you want to be able to dynamically um load any subdomain so anything doot local host.net you can add what's called a wild card domain so if you do a star right here this means anything. notloc host.net that doesn't appear in this list right if it's something that doesn't have its own specific entry will resolve to whatever you specify right there and that allows you to have like Dynamic do subdomains especially using something like coolify where you want like a versell like experience where every app has a unique subdomain so wild cards are something I'm going to talk about in the next video so um thank than you to both kishan and E Cognito for those questions I'm going to jump back into the chat see if we have any other things that are popping up IP address yeah um I was looking at bit bucket to store secrets on a VPS I haven't done that
Responding to Chat
specifically I wonder if they have a product offering for that uh yeah so twitch uh V turkey says where did you put the secret coupon in the video so if you missed it uh in the video I at the very end of the video specifically this last one here about caddy I mentioned somewhere there is a place where you can find a a way to get a free t-shirt and it was actually just in a text record so that text record is still there I but it uh it doesn't have the link to the form anymore but if you just did a a dig on not loal host.net and searched for text records you would have seen this text record and it had a link to a Google form so uh the first person to do that was Eli and they got their free t-shirt and then in the previous video so in the very first video uh I made it so that anybody that went to the IP address of the server literally hosted on the website so not local host.net uh it just had a link right here to a form and uh Matt kill cup was the one
that found that U so every video will have something slightly hidden in it that could potentially get you a free t-shirt so yeah welcome in Randy good to see you good to see you and welcomeing everyone over here watching on uh on Tik Tok as well hello hello all right let's get back into it um actually we have a comment from Stony Eagle so cloudflare with a reverse proxy in a Docker container is amazing for collaborating with the streamer and having live reloading without leaking my IP and having SSL I believe we're about to talk about the uh Cloud flare uh reverse proxy but I could believe it yeah because cloudflare can potentially hide the IP address of the server that you're working on yeah uh Demetrios is asking can sqlite scale and how does replication work across regions I think of it like simple files but nowadays it got complicated yeah personally I don't have a lot of experience with it but my understanding of it in terms of uh using sqlite at the edge so there's this idea of using a sqlite database on edge
functions and I believe that just is replication so every single edge function literally gets a sqlite flat file and its changes are written to it and then those changes are replicated across every other Edge instance that has a sqlite flat file on it that's my understanding I I'd have to dig deeper into it but that's essentially how they do it because sqlite is a flat file database it it's yeah it's it's literally just that so yeah uh roel is asking should you host your own mail server probably not that's actually one of the last questions we're going to answer today I have some resources for you but hosting a mail server is not easy because of uh spam and also this idea of IP address reputation so we'll talk about that uh hako is saying in our team we use a LEL API and we use cookies for off but it's need it needs to be on the same domain to work yeah these days it's really hard to do cross-site cookies so um yeah is there a way to Tunnel out all local host and add the same domain yes
that's a reverse proxy um and actually if we look we're all over the place today but that's okay I feel like it's more fun to answer the questions as they come up than just stick to a specific C uh script but if you look at reverse proxy in the uh caddy directives they actually have an example of this where you can essentially have a combined website where the root of the website is served via a static file server uh but then specifically just for the SL API route that is served via a reverse proxy so as long as your API is being served at a unique URL that doesn't interfere with your client side files you can set up a reverse proxy this way um that's I mean it's it's pretty much just this so you have your top level caddy file and uh above this you would have a file server directive and then point to the folder that you want to serve the files from and so most of the website it's going to be served from those static files but if someone hits
SL API or in this case SL prefix that's going to be reverse proxy to wherever your API server is running so that's an extremely common way of doing things where um it's all served from the same domain but technically the IP is the API is hosted somewhere else or it's running on a separate Port but it all is is hit under the same domain cool good questions everyone good questions all right let's get back into it um next up uh Vincent Pena says this is what I need please for the next video uh could you do a guide for securing your server from DDOS or distributed denial of service thanks CJ oh you're welcome uh kishan also says why not use the cloud flare proxy to mask the VPS IP isn't that a common practice it is and we'll talk about that so and also jit X says uh I think by disab disabling the cloud on cloud flare we're missing a lot of cloud flare features like caching and security and we can hide our external IP address behind the cloud flare proxy let
Cloudflare Proxy / DDOS Protection
me show you what they are talking about so uh on cloud flare if you saw in the last video I was setting these records but whenever you set a record on FL Cloud flare they have this option for a proxy now the reason I didn't show this in the video is because I wanted the tutorial to be relevant for people that weren't specifically just using cloudflare because all of the stuff I talked about for DNS uh is general like anywhere you manage your DNS you can use what I talked about to do that there the cloud flare proxy is specific to Cloud flare there are other services that offer it but not every DNS provider offers it um and essentially what it does is it proxies all traffic through uh cloudflare so that way there's multiple benefits one of them is you can hide the IP address of the server so let's actually enable this uh here and and see it see it in action so right now when we do a dig for notloc host.net and we're looking for a records this is revealing the real IP address of the
server right so this is the actual IP address of the VPS that I set up if we enable the cloud flare proxy let's do it we check the button we click save it's going to take a second for this record to expire remember because I set a 60-second TTL but uh this was pretty instant so you'll notice now when I query for it instead of seeing the IP address of my server I'm seeing the IP address of cloud flares proxies and actually this is a this is a a fun little thing we didn't talk about in the video but technically you can have multiple a records that point to different IP addresses and this is one one way of doing load balancing kind of like at the DNS level so when a client looks up a uh a domain to point it to an IP address if it gets multiple records it might try both of them there might be logic to try the one that's closer to it geographically but we we right now actually have two servers that are sitting in front waiting for requests and any requests that come into these servers for this domain are then going
to be proxied to our main server and so the first benefit here is we actually don't see our server IP address uh listed whenever we do do a dig these are actually cloudflare IP addresses um and so we should still be able to go to the website let's try it yeah still resolves but technically it's routing that traffic through cloudflare and cloudflare has a bunch of other features including uh one of the things you can do is distributed denial of service protection where you can put up a capcha so if you go into DNS actually no if you go to the overview of your domain there's this little check box right here that says under attack mode and if you check this every single visitor to your website will have to either do a capture or just like prove that they're a human and you've probably experienced this before like you've if you've gone to a website and you had to put a capture in and you saw like the cloud flare logo that's what's happening and let's enable it so let's let's click this we're under attack and then it's Poss I tried this
earlier so it's possible it won't work for me but let's see if I go to The Domain so if I do a a hard refresh so uh don't load from the cache yeah you can see first we see that cloud flare page it knows I'm a human because I'm not doing anything malicious from from my IP address so I don't even have to do the capture it just takes me there but I want you all to try this I'm going to throw the link in the chat um try going there you should actually see the cloud player uh unless unless the page is CL cached you should see um yeah autoc Canon the site so uh Ben is mentioning autoc Canon so autoc Canon is a way of uh automating requests and like load testing a website uh so we could do that we could we could potentially try to fire requests against it but because that cloud flare page is now in front of it uh that's going to stop any traffic before it even hits our server and they have to do the cap sha now there there are ways for or Bots or in whatever else to get around Capas but it is one one level good level of of protection but
let me know in the chat are you seeing that that cloud flare page um but let's see they asked for the caption nice nice and so that that's uh one simple way to help with distributed denial of service attacks so Cloud flare has a huge infrastructure they have this on the free tier so you can even use this without paying them a monthly fee there are other service that that do a similar thing uh but this is one way of doing it if all of a sudden your website is getting flooded with a bunch of traffic you enable this that's at least going to stop some of the traffic beyond that it really comes down to your actual application code so you can do things or potentially like your load balancer code or configuration you can do things like rate limiting so uh based on IP address you can limit the number of requests that are coming in and if too many requests come in you can block those requests um you can also lock things down behind uh authentication so that way everything fails unless it actually the the user is logged in and they're a
valid user so there are more things you can do beyond the just like this attack mode from cloud flare uh specifically talking about um uh distributed denial of service attacks um but yeah yeah yeah yeah so let's see uh Osa says or USA says I am officially a human nice uh and bmine says it let me pass confirmed I'm a human nice glad to hear it uh bindle Jen says can I self-host dos protection there's probably a product out there but I have not looked into it um but it seems likely I I I don't think cloud flare offers their services to be self-hosted but um ultimately what you would need to do is just set up extra servers right so if you if you had some uh requirement to set up this uh uh dos protection you you're essentially setting up load balancers in
a way so you set up servers that are going to proxy request but they have the configuration to uh block multiple requests or the if it's the first time that it's seeing an IP address it could potentially throw up a a static page um the more I think about it like yeah I could build that I could build that but uh there's probably a self-host option out there somewhere nice um cool cool cool cool cool all right let's keep moving uh and Stony says uh against script kitties you just need a good CPU and a ton of RAM on your router nice um cool all right more questions let's get back to it uh so yeah uh why not use the cloud flare proxy to mask the VPS isn't that common practice um we just talked about that so one of the things I will mention I was testing this out earlier and I ran into a redirection loop so one thing you want to do specifically if you're using Cloud flare is you and if you've set up https
redirection with caddy on your server you need to enable full TLS encryption mode because without it cloudflare will make an HTTP request to your server and if you remember caddy is serving up https redirects so if we do a curl against our server and show all the headers so if we do uh not local host.net specifically we're requesting over HTTP not https um well actually I forgot we set up Cloud flare so cloudflare um is actually responding with it with the https redirect but let's let's see if I can easily disable Cloud flare without waiting a while and I can show you that that caddy header that gets set um but ultimately if you don't configure this correctly it creates a redirect Loop because cloudflare requests HTTP from your server that responds caddy responds and it's like oh hey you should load over
htps and then um uh Cloud flare attempts to make like an HTTP request to an HTTP side it's just like an infinite Loop so what you need to do is if you enable full uh encryption like I showed here that makes it so that cloud flare makes an https request by default to your server instead of an HTTP request but let's see I just disabled Cloud flare yeah it's going to be cash for a while um and if we if we try doing another dig record oh it should be
back Cloud FL is still there we're dealing with caching at this point because essentially um we set that up and we're going to have to wait for the cash to clear it looks like the a records cleared up pretty quickly but uh I will just mention this if you enable that make sure you check this box here and if you don't check this box you would have to disable https redirect within caddy which is possible but I would recommend just checking that box there cool all right did I miss anything else here yeah that's the main thing you can hide your IP address you can very easily prevent distributed denial of service attacks so yeah what else we got um oh yeah oh good call Stony Eagle um I completely forgot about that so right now because I'm dealing with that cached page uh we going to disable I'm under attack but also there's this option here called development mode and that will just disable the cach entirely so if you're dealing with cached issues on cloud flare check this box and that should prevent loading stuff from the cach let's see if that that actually worked quickly
um it's going to take a second it's a for whatever reason I mean it could be that this is actually cached locally to my machine geographically um but yeah all right any other comments or questions before we jump into the next question yeah oh good call uh Julian is mentioning I forgot to turn this off but like technically I um I disabled the proxy altogether so if you don't have the proxy enabled here the setting over here shouldn't affect it but I think I just have to wait at this point um always set it full nice uh I miss this and what's up Mike the tree climber have you talked about the difference between a and AAAA names and C names I always have a problem wrapping my head around that stuff every time I set up a new site uh I did talk about it uh a little bit and if you haven't seen the video that I did about caddy the first
A vs AAAA vs CNAME Records
10 minutes of the video I talk about DNS and I talk about a records and and cname Records I don't talk about quadruple a records and quadruple a records are just a records but for TV6 um so let me show you but and and I'll run through the what they are really quick because it's not too bad so when you see an a record think IP address IP address IP address if it's an a record it is specifically pointing to an IP address of some server if you see a cname address that needs to point to a domain so uh we actually have a cname set up for banana so when you go to banana. notloc host.net that DNS is going to resolve to this domain but that means we have to further query for it so C names get set to domains a records get set to IP addresses it's it's as simple as that uh and then beyond that AAA records are for IPv6 um and so IPv6 is the newer version of of uh Internet Protocol addresses and
they look very similar to Mac addresses but you really only set these if your server supports IPv6 like if it's connected uh to a network and it has an IPv6 address right now when this when this live stream is happening a records are still kind of the main thing and IPv6 is is somewhat more is somewhat more rare like you there are people that have internet connections that actually don't even have access to the IPv6 uh address range um so there's specific applications where you would you would specifically would use ipv uh IPv6 but all of that to say quadruple a is an IPv6 address single a is an ipv4 address yeah uh can you you can Purge the cash from cloud flare is there an option for for it somewhere let's cancel this oh here's caching I think the issue is I it's not even caching the page it's like caching
Responding to Chat
the the redirect it's caching the the main the redirect itself not the actual not the actual page Purge everything let's try it um please allow 30 seconds for the changes to take effect yeah on heter you get an IPv6 for free but you have to pay for ipv ipv4 yes that is the that's actually the the growing Trend so AWS light sell made an announcement recently where um if you are keeping your ipv4 address the price of your VPS increases by like $2 or $3 maybe $4 um it's because we're we we have run out of ipv4 addresses it's actually a fast fascinating problem if you if you're not if you haven't really looked into it um so if you look up IP addresses they um oh well I just leaked my IP address it's okay I can very easily change it uh look up IP address on Wikipedia um and uh they talk about the
potential number of available I can't believe I just leaked my IP address it's fine it's fine do not dos me uh I also have a firewall on my network and I can change my IP it's fine um you can see here the the potential number of network addresses so um yeah so it's something like I guess this is only 16 million is that true there's a limited number of IP addresses given that let's say all of the IP addresses from 0.0.0.0 all the way up to 255.255.255.0 and then you actually have to remove some of those ranges because some of them are private um and uh some of them aren't included in in the public IP address range and that's the total number of IP addresses available for all possible devices but if you think about modern day everyone has like multiple devices that need IP addresses and so we've we've essentially run out of IP addresses that can be allocated in the ipv4 range which is why IPv6 was was
introduced because it can support billions billions and billions of devices yeah cool um it's fine it's fine right it's fine um let's see can you move DNS from versell to cloudflare I think I've heard previously versell doesn't work with Cloud flare DNS uh as long I actually haven't used versell to buy any of my domains but as long as versell lets you set custom name servers you can move to Cloud flare and I would imagine that they that they would most DNS providers give you the ability to change your name servers and if you can change your name servers to point to cloudflare then that means you can completely manage it from from cloud flare um Now setting that up in front of a versel deployed site I don't know that could be a lot trickier be um I actually have no idea how that would work or if that would work but that that might be what you need to be worried about is you set up the cloud flare proxy but now it
needs to make requests to the versell function and maybe you need some more settings there but yeah um cool and what's up in codes who says can you do a walkthrough of self-hosting coolify that's the next video so I'm I'm looking into kify I'm learning how to use it and I am making a video on it that will be the next one that's out um if you find my house don't say that um so many open ports there's not I literally have a firewall Appliance and it doesn't allow outside connections come on people um IPv6 could last for a whole year yeah I mean right now we think on the scale of things we think I will never run out of IPv6 addresses just you know but who who knows yeah cool oh yeah and the the cloud flare Dev
mode does disable itself after three hours cool didn't know yeah I mean they're not as common just because IPv6 addresses aren't as common what's up alexr welcome in welcome in uh it's going well we're answering questions I just leaked my IP address it's just a we're just having a regular old time here uh can I cover reverse proxies check out the last video that I did on U on self-hosting so in this video I talk about what a reverse proxy is and I show you how you can start up a node.js app on the server running on Port 5,000 and then reverse proxy that to a domain so definitely check out this video here um I don't think we have streamlabs here but I'll link I'll link you the playlist this playlist has all the videos you want to look at the one before this and that talks about reverse proxies cool uh and N code says uh had a hard time getting kifi to work it looks so cool thanks for your service honestly me too but I'm I'm I'm taking a bunch of notes as I set up kify kind of just
talking about um what I had to go through to get the thing working and for the vid the video I make it's going to look like it's going to be the happy path because I'm going to show you exactly what you need to do but it is taking a lot of uh back and forth to figure things out uh what are my thoughts on traffic it's pretty cool um so let me show you traffic if you have not heard of it it's very similar to uh caddy and I I I touched on this in the last video that I did but one of the nice things about traffic is they have this built-in web dashboard uh and actually kify initially was built on top of traffic in the latest version they're actually adding cadd support currently it's experimental but before it was all based on uh traffic and you can actually once you set up kify you can enable the traffic Dash board this will show you all of your running Services it'll show you your middle wees everything else um and uh so it's pretty slick I I think it's it's very
similar uh to caddy in that a lot of things are zero config like you can just say I want TLS with let's en Crypt and it'll automatically provision that certificate for you um but I don't I don't have as much experience with it but yeah traffic is cool you you essentially could use that instead of uh caddy when would you use cloudfront versus cloud flare uh Cloud front as far as I know is an AWS offering that uh is a CDN I don't think cloudfront has DNS protection yeah so cloudfront is specifically a CDN CD in and caching is one offering that cloud flare has so really this one tab here is the equivalent of cloud front um and I haven't really done this with with Cloud flare before but I have worked with with Cloud front and uh it's an a AWS offering essentially you can point it to like an S3 bucket and it
will uh uh cash any requests to the files from that bucket you could if you set it up as a website and also distribute those across the world in a CDN so that's what cloudfront will give you and then cloudflare technically also has a cashing CDN when you make request to sites um what current production apps have you worked on currently the tax website because that's that's where I work um yeah so this is what I work on this is in production i' I've added a have I added features I've kind of fixed some things here and there um but that's the site that I'm working on it's built with spel kit it has a mySQL database yeah uh can I go over pm2 yes there was a question about pm2 that I'm going to cover and I will touch on it tried IPv6 with coolify couldn't get it working yeah related to lack of support in the UK yeah that's what I'm saying is like not everywhere actually has support for IP IPv6 yet eventually they will and they're going to have to because we're
running out we have run out of ipv4 addresses but yeah uh yeah Palo says I think you're right in saying there's a ux problem in general but I had a really pleasant experience setting with kify yeah I mean my I'll talk about this in the video that I'm making for kify but really my main takeaway is kify is built to kind of streamline using a lot of these tools that we typically use from the command line like Docker traffic caddy um are there others some of the the various like Docker specific and C plugins and caddy plugins coolify is just like a nice UI built on top of those things those things that tries to make it as seamless as possible to set up what you want but if you run into issues you're potentially going to have to dig into like the docker file or the docker compose file or the traffic settings so um once you start hitting issues it gets harder to figure out where do you go to to fix things because it's using those tools under the hood but
yeah uh any suggestions on services that help you monitor your VPS uh Sentry let's talk about centry how long have I been live I've been live for almost an hour Sentry will let you know about any errors that are happening in production check it out um specifically you can add it to your backend code you can add it to your front end code and anytime an error occurs it is going to uh log the issue and all the information and stack Trace associated with it and then you can actually go in and debug it so if errors are happening in production from an app hosted on your VPS centry can help you with that and centry also is self-hosted uh or self- hostable so you you don't have to use the paid offering um you can host it on your on your own servers as well uh and they have a whole whole infos about that here now that's just one aspect of monitoring your VPS s is like letting letting you know that errors are happening you potentially also want to know well did did a server
go down different stuff like that and that might be specific to spec what you're running on your VPS but there is this idea of like status pages and and alerts so um I think there's a page for awesome status Pages yeah uh I was looking into this because for the coolify video I at least want to have one of these set up but one of these to look at is like open status which is a pretty cool one it's built with an xjs um and if you've ever seen a website that looks like this that says like how much uptime do we have and what are some recent events uh this is one of the ways of getting that going so open status has a uh hosted offering so you can pay them and uh they'll host the status page for you but you can also self-host it because if you go to it it's literally just like a nextjs app in a repo um and there's a bunch of other the a bunch of other uh status Pages as well and and this is what you would want essentially a lot of these status
Pages um essentially you would host them on a separate server from your VPS right so like if your your VPS ever goes down or there's issues or whatever else that status page software potentially also has some uh alerting built into it so you can do like email alerts or SMS alerts so if a server stops uh if the if the health checks ever go down for a specific server it will let you know know about them um so that's definitely another way to monitor your VPS is there a difference between let's encrypt SSL and buying one the only difference is the certificate Authority so um yeah let's let's look at let's encrypt they are a nonprofit certificate Authority so you may not know this about uh TLS certificates for websites but it's all based on this idea that we trust the certificate authorities and so there are various certificate Authority out authorities out there uh before
Let's Encrypt and Certificate Authorities
something like let's encrypt you might have heard of like kodo Koto SSL there's probably a few others that that popped up but basically they were the certificate authorities and every machine trusted them and every machine actually has a list of certificate authorities that they trust and that means whenever your machine is looking at a TLS certificate it's going to check to see was that certificate issued from a certificate Authority that it trusts and every browser comes built in with a list of certificate authorities that it trusts authorities can we get a list of
them yeah so you probably heard of diger global sign uh GoDaddy has their own so basically every computer has a file on it that says I trust these these certificate authorities and so when it's looking at a TLS certificate it's going to say well is that TLS certificate issued by one of these certificate authorities and one of the initiatives of let en cry was like we're a nonprofit We want to become a certificate Authority so we can give away TLS certificates for free so the only difference of certificates obtained from let's encrypt is that your certificate Authority is is this entity called let's encrypt versus these other entities like dig aert and Global sign and stuff like that um but at the end of the day it is still just a TLS certificate so yeah and uh in the I think was it the last yeah was the last video I was making technically they're not called SSL certificates anymore I I still use SSL and TLS interchangeably but if you want to be technically correct you should call them TLS certificates because SSL
is actually a very outdated technology um it uses TLS encryption not SSL encryption but you can still call them SSL certificates um if we hosting on yeah so that's the other issue of hosting a status page on your own VPS is if the VPS goes down then your status page goes down which is why you have some kind of redundancy right you have um a uh another server or potentially you could even host it yeah host it on a a host one thing on AWS because you can trust their infrastructure or something like that but you would need to host it separately to make sure that it stays up yeah so uh so that's another thing so status page will let you know if they go down and then I will show you uh a uh pm2 which is a dashboard that shows you some of the processes you have running in the background and you can potentially set up alerts there too so like if the CPU usage goes too high or uses too much memory or something like that that can
Responding to Chat
start alerting you I'll show that in a little bit uh franois says the main thing that worries me with VPS maintenance is that all this setup is manual any chance to cover automation backup and restore strategies and migrations I want to do that eventually I don't think I'm going to do it anytime soon because I'm going to start working on other types of videos but yes that that's really the kind of stuff that you need to worry about is um yeah making sure you have backups making sure it's easy to spin up new servers making sure you have processes in place to use uh uh SSH keys and stuff like that um I want to cover that eventually I I don't see it doing it it anytime soon just because we're going to be focusing on more like webd stuff because we have been doing a lot of VPS stuff lately online SU is saying the duration is also a difference let's encrypt CTS expire in 3 months typically when you buy a CT it's valid for 12 months yeah and that's ultimately I think something they decided to do to prevent abuse and like overuse but there are a lot of tools in the ecosystem that can do automatic renewal especially if you have
like your DNS records set correctly and everything so everything I've used let's encrypt for I've never had to manually review except for wild card certificates Wild Card certificates do have to be manually renewed but there are tools for automating those as well but yeah that that's a good distinction to make but ultimately the validity time is up to the uh certificate Authority yeah but why does my browser trust let's encrypt because actually I don't know the hierarchy of it like I don't know uh where it goes beyond just being a certificate Authority but because they are one they are officially listed by all major browsers as valid as a valid uh validator of and creator of certificates that's why yeah what's up moshiko good to see you uh Haka says I love the pm2 saw it on your video and already using it nice nice appreciate that Francois does uh centry have an easy migration path from self-hosting to the cloud offering that is something that I do not know um but they probably have
some docks on it let's just see I would assume so because it's it's in our it's in our business to uh uh potentially make money if you don't want to self host anymore
productionizing it's probably possible I'll find I'll try to find a link for you and send it to you later uh bmine says I still call it SSL certificates I called it SSL certificates until I started preparing this video uh just because I saw people talking about how it's well it's technically not SSL certificates anymore what's up Amir welcome in um all right let's keep going here we go that was a lot of uh down the rabbit hole but that's okay and we're going to talk about pm2 now so uh raser says this is very nice I learned a lot I love pm2 and all the reports it gives is there another way to monitor the application without being sshed into the VPS so let me show you so uh I showed you in the last video how to use pm2 which is a process manager and essentially it manages uh background things things running in the background so if I SSH back into my server and we just do a pm2 list uh pm2
pm2 Web Dashboards and Monitoring
is managing these two node.js services so I have an API hosted here and an API hosted here and if they ever crash pm2 will automatically restart them and pm2 keeps track of all the logs so if I do uh pm2 logs for example API we can see all of the requests that come in and then uh if we go to the site so if I go to example api. not local host.net that request comes in and we see the logs here so uh it it it's showing us the logs here it's storing them as in a specific spot if this server ever crashes it's going to automatically restart it um so pm2 is is pretty cool for that and uh it's it's built with node.js and you typically use it to host nodejs things but it can host any kind of
process uh in the last video I talked about how pm2 is an option but you can also use something like systemd so systemd is built into Linux and allows you to create these services and it'll automatically restart them but let me show you some of the other things that pm2 can do now uh pm2 plus is a paid offering so if you look at their pricing it actually is $40 a month um it's kind of pricey but I'll show you what it can do and you can decide if if that's actually worth it but they give you a dashboard like this that you can access externally so I just signed up for the free trial and I have my instance connected and so if I go to this web page it will show me those same processes but I don't need to be sshed into the server so I can see how much memory the process is using I can restart it with like one click look at that uh I can see all of the logs so it's it's pretty slick to be able to see all of the running processes on your server um and they have a bunch of other features that I haven't dug into as well uh and they have like profiling somebody
earlier asked about monitoring they very likely have a way yeah alerting look at that so they again it's a paid offering because there's a lot of features that they're adding here uh but they do have a way of saying oh well if my if my process uses too much memory send me an alert or whatever else so um it's pretty slick uh um I guess maybe I'm not on the free trial anymore yeah and I think ultimately basically what has to happen is there is some process running on this machine now that I've connected it that is uh very regularly sending all of the logs and all everything else to this remote server so that way I can go in and and see the actual status so uh that's a thing now again it's a paid offering you can decide whether or not the price is is you're you're willing to pay for it but I will say there are some open source projects that people have tried to do a similar thing so I haven't used any of the but if these if you just search GitHub for pm2 web UI you can see
there's a few popular ones that people have created where these are completely open source and it basically just gives you a web page with the with with similar features where it kind of shows you all the stuff happening inside of pm2 so these might be worth checking out I haven't tried any of them uh but it gives you a a similar thing and uh one thing you could do is if you're going to host it on the same server as you could just like reverse proxy it to a domain but again if your server goes down then your entire pm2 monitoring goes down so this idea of like a a remote way of sending off your logs and metrics that way if this server ever goes down this server over here is still able to know about it that's potentially something you want to set up but uh that is a possibility with with pm2 so yeah I'll jump back back over to the comments see if you have anything else for me yeah I call them https certificates I think that's the better way to go because you don't run into the issue of accidentally
saying SSL or TLS they are https certificates yeah well honestly it's I don't think it's worse I think it's okay to say that um what Hardware am I using for my Home Server I've recently started to build my Raspberry Pi minir rack I haven't spun up my home server but because we're here I'll I'll grab
Home Lab Hardware
it's so it's a Dell Precision t5610 and uh I'll be honest I got really excited about like home lab and self-hosting
and I set it up with a raid array and a bunch of stuff but then I uh I didn't have the time to work on it so it's just been sitting there ah so Tik Tok is having me verify that I'm a human that's really weird okay hopefully Tik Tok is still live um but uh so if you're looking into home Labs that or if you're looking into self-hosting at home home lab is what you want to search for people talk about it all the time like the kind of servers you can use like raspberry pies or just a laptop uh specifically this um Dell Precision is like Enterprise level desktop and the reason I chose that is because uh it's not super loud it still has like an Enterprise grade CPU I think it has like a Zeon Intel CPU so um it still has to cool it and so the fans do spin up but if you've ever heard
a real server the fans get so loud and you don't want that sitting next to your next to next to your desk so yeah can I compare pm2 to supervisor I haven't heard of
Responding to Chat
is ah I have never used it so I can't compare it but it's good to know that it exists yeah yeah uh Scott mentioned that to me so his home lab is running off of a Mac Mini is that what you have coolify running on yeah that's awesome uh my plan is to make the raspberry rack as a cluster so I can learn more about k8s and Linux yeah I've seen some tutorials on YouTube about that where people get a bunch of raspberry pies because they're cheap and then you configure them all in a cluster yeah uh I know people say you need Linux but Mac is silent and pretty powerful for the price just not as many available tools yeah how to burn your retinas oh the website was so yeah I agree um P says speaking of which in theory you could host kify on a Raspberry Pi you can even do that with tunneling without opening any port um one thing I was curious though is if I tunnel should I be able
to do it without a static IP yeah that's one of the so that's another offering from cloudflare is the cloud flare tunnel and in a way it's kind of like Dynamic DNS as well so because everything is going through the tunnel as long as you have that client running on whatever you want a tunnel its IP address can change like your your home IP address doesn't have to be static because it's always allowing the connection via uh Cloud flare and then the cloud flare thing that you set up has a a static IP address or an IP address that gets updated if it if it does change automatically yeah what's up killer uh I know I know I can install Docker on a VPS and run my images in production but continuous deployment would be a pain is there an open source solution that makes this as easy as fly.io um do you mean like rebuilding images repoing the latest image that kind of thing killer is that what you're talking
about uh you have two wait wait wait you're are you talking about how I I I uh I no longer I I got the thing decided I wanted to do it and then just like ran out of time or didn't have the time to to do it uh Stony says I have two Dell power Edge blade servers and they're loud yeah um can you give me an overview how to migrate to es 9 I haven't done it yet I haven't done it yet I thought they had an aut an automated tool that could do it I thought there was a script you could run to automatically upgrade but eslint 9 uh I believe they've completely switched to this idea of composable config files instead of like your RC file but yeah watch me run coolify on my phone that's great all right let's get back into it next question comes from multiple people and we're actually about to talk about how to do cicd on a server so uh yuchai uh hio says next video should be cicd
CI/CD on a VPS
with GitHub actions uh ryer da also says another way we deploy V and other statically built applications is to build them with GitHub actions and then copy them to the VPS I never tried but I've seen examples online yeah in the last video um yeah we had a static react app that had a build process and I showed you that technically you can just run npm run build on the VPS itself but if that build process requires a lot of CPU the other services running on your VPS could potentially be degraded when you're when you're needing to build that that front end site so doing offloading that to some build server is definitely a way to prevent reducing that load on the server and Juan Moses Trio says excellent quality thank you for the this question how would I set up automatic deployment in my VPS and W salom says these videos are amazing great job would love to learn how you would approach cicd let's talk about it and I have a have a few
links for you so first of all one thing you could do is run something that automatically syncs your git repos now uh this will work if it's just like a static website right so if if you're serving up static files and that lives in a git repo and then you make a push to that get repo if you pull those changes on the server you don't need to restart the server you don't need to rebuild anything as long as those latest changes are pulled in then the latest static files will be served up and there are tools that can automatically sync git repos so get sync actually comes from the kubernetes team and it installs a Damon that uh is just always running in the background and instead of using git clone you use git sync clone and after doing that uh it will keep the repo in sync I believe it does like yeah it does a poll to determine uh if there are latest changes and so it's constantly running in the background it's like are there latest changes on the repo are there latest changes and when there are it pulls them
in and so get sync from kubernetes is one way to do that and there's also this one called git autosync which comes from git journal and it works in a similar way where instead of doing git clone you do git autosync clone um and I think they also have like a sync command and then there's like a a Damon that can run in the background um if you're still watching Scott we should add Damon as the uh a word to see how people pronounce it because I've heard this pronounced as like demon or Damon I think lately I've just been saying Damon but both of these tools are running on your server and they will automatically pull any changes into a git repo and so that is one step of U uh continuous deployment in a way but for a lot of use cases you need more than just that right you don't not only do you want to pull in the latest changes you potentially also need to run run a build uh and other things like that so uh one of the things we can potentially do this
with is web hooks so GitHub has this idea of creating a web hook on your repo so that anytime something is merged into main the GitHub servers will make a post request to some other server and that some other server is now alerted that there are changes on the repo um and you can do this with any repo on GitHub so I'm I'm here in this not Local Host .
net repo if you go into settings and then web hooks you can specify a URL and uh like a secret that you could potentially validate on your server and then now all you need is some server listening at that specific endpoint it can be written with anything you could write it with node you could write it with go you can write with python as long as it's a server that can receive post requests it will be alerted when some change happens on your on your GitHub repo and other services like like bitbucket and uh gitlab they all have a similar way of creating these kind of like web Hooks and so this is one way to uh start with the automation of uh pulling latest changes or running the latest build or something like that so you could set up a web web hook and then you uh you could you could write a custom server that listens for that post request and then when it receives that post request it just runs a script right it could run a script that builds your app um that uh restarts the app th those kinds of things and that's and that script can do literally whatever you
want so that's one way of going about it but there is this really cool tool called Web hook and uh it's written with go but you can just run it as a process on your machine and so you install this now it's always running in the background and you would potentially set up like a a reverse proxy setup so that you have an actual URL that g GitHub can make a post request to and they have a really easy way of configuring it so you give your deployments unique IDs like I would create a deployment called like not local host.net and then you can specify a script that should be run so for example if we're trying to deploy like a react app we could add the web hook make sure that this is running on our server uh create a reverse proxy with caddy to put it behind a subdomain and then write a script that does uh npm run build and then um pm2 restart or like restart the service with whatever you're using but that custom script could could be there and so uh this project has a has a ton of stars it it
is very popular and basically you could use this in conjunction with a caddy reverse proxy to now automatically pull in changes and build um whenever there's a a merge into main on your main repo so that's one way to go about it now the other aspect here is you're still running those Builds on your VPS and that's not ideal because if it's a very heavy build process then everything else running on the VPS will potentially your services will be degraded because your VPS is spending all of its CPU trying to build these apps so for that you potentially want to would want to introduce like a a build server some kind of intermediary um and a fairly easy way to do that is with something like GitHub actions so uh GitHub actions does have a free tier but this might be the even with self-hosting this might be one of the best ways to get a build server is just by using GitHub actions because you could create a GitHub action that
whenever you get a PR you uh run your tests you run your build and then you combine this with the SSH action and that could SSH into your server and like load the built files itself um or you could do you could do it all on the server itself so you could create a GitHub action that uses this SSH action uh action and you can see that you can specify a script you can do literally anything you want here so in the GitHub action you could actually have a script that says SSH into the server build it or pull the latest changes build it and then restart the service but you could do that with SSH actions um and then I guess if you're if you're not on GitHub other services have uh get up action style things um but beyond that it really if you want to roll your own it kind of would come down to setting up a separate VPS and then just setting up SSH keys so that that the vpss could talk to each other right so you could have
the uh web hook server running on a separate VPS when it receives its uh hook that things have changed it can pull the latest changes run the build and then from there if it has an SSH key to be able to connect to some other server it can SCP those files over to the other server and then you could run a script on the remote server that then restarts the service I don't know it's it's it would be very manual to do but basically you can use all of these building blocks to kind of get that same automated deployment and build process that that you're kind of used to the other thing is to like use a tool that kind of mostly does it for you so we're going to talk about kify in the next video and they have this idea of GitHub integration so you can set up an app that points to a GitHub repo and then you set up a web hook so uh uh kify will create that web hook endpoint for you they basically have software running behind the scenes that works very similar to this this web hook tool that I'm showing you here and then within coolify you have build settings for your
app so when it receives that web hook it can rebuild the app it can restart it it can it can do all the things that you need so um there's a lot of ways to go about it but ultimately that's that's how we get automated deployment automated integration um and like I was saying you you if you use all these building blocks you can have a separate build server you you can kind of like move beyond the basics there Wes says demon nice uh so we were talking about Damon versus demon all right let me catch up on the chat but that that's that's how you get cicd on your own custom server let me know what questions you have um yeah kify also provides yeah so that's what we the last thing that we touched on is if you want automated G GitHub integration and and everything else coolify has that and coolify has an experimental feature right now of build servers so I think that's actually the next question we're going to get into yeah well at some point we have a question about build servers which is what I talked about a separate server that does
the building so you don't use those resources on your main VPS um yeah it's clearly pronounced Damon demon uh laravel Forge is perfect for cicd it allows you to deploy from your ca oh cool yeah I guess one thing I didn't touch on is um I mean I don't know what the self-hosted versions of these are these days but back in the day I used a things a thing called Jenkins CI so Jenkins uh is self hostable I think it's built on top of java and uh Jenkins is what we use before things like TR a ACI and like GitHub actions and and all these other more like uh hosted platforms were created and you host this on your own server and uh it has ways of configuring all this stuff so like it it can listen for for um updates to a repo it can do the builds it can do all that stuff and
so I don't know I I I'm not up to date I don't know what the modern equivalent of Jenkins is or if people are still using Jenkins if they're hosting their own CI but in a way Jenkins is kind of like your own GitHub actions you you basically can configure it in the same way that you can you configure actions but it's running on your own server what's up ronado welcome in oh we answered your question if you missed it we were talking about pm2 uh we do that for a react front and a lville back in nice yeah oh yeah you saw it nice nice uh anyone have recommendations for a 2.5 gig Nick which is a network integrated uh device thingy uh I don't uh W salom says my first thought was get up actions but the web hook package also looks really interesting yeah let me let me get get you all of these links so uh yeah the web hook one is is a little more configuration um but like I said it's you install it create a reverse proxy to it and then it you just add a little config and it's kind of like good to go and then the other thing are like these
tools and also the the SSH actions so if you're going to use GitHub actions the SSH s accent is a good place to start what's up Muhammad welcome in yeah I have a lot of tabs open I do I do um deployment rolling out uh restarting on failure I guess I would need a private registry as well yeah technically if you're on the GitHub Pro Plan they actually do have a private registry for Docker images if you if you didn't know that you can host Docker images on on GitHub like the GitHub packages feature um but all of what I just talked about I think would apply here as well but you're going to have to combine that with like the docker CLI and the idea of like instead of just running a build with mpm run build instead you would run the the docker build command and and stuff like that so yeah yeah get Hub actions are a pain to
debug Scott was dealing with that recently he was setting up uh like markdown validation in a GitHub action and being able to debug it is like you want to run those actions locally first to make sure that the stuff is working so you don't have to keep pushing to the remote but yeah uh Adam cier says good night from the UK we'll catch up on the rest cool I think I'm answering one of your questions but yeah we'll see you thank you for dropping in and thank you uh it's no fun um all right let's keep going next question is from Amir zi it says love the series uh looking forward to seeing solutions for better isolation between the apps like nested virtual servers Docker Etc and pexer says this is awesome I would love to see how you would set up and manage Docker and AD DB on the UPS yes yes yes yes I think it would be fun to just install Docker and show you how it works um so I did do a video called start using Docker today and um
Running Docker on a VPS
this shows you the basics of Docker but really with a focus on doing it in in development I don't really talk about like building and Publishing IM and um like pulling in those images and stuff like that but most of what I talk about with the docker CLI and Docker compose you can do all of that on your VPS so let's do it let's do it live I'm going to install a Docker and then just like spin up a container and then reverse proxy it through caddy because uh if you saw in the last video I talked about how caddy could reverse proxy anything running on a specific Port as long as we can expose whatever is running in our Docker container to a port we can reverse proxy it through caddy just like we do any other app so let's go let's install it on ubun 2 wait I don't want I don't want
Docker how do I get that Docker desktop is specific I mean I guess technically you can run it yeah Docker engine that's what I want Docker engine all right uh we're running on Ubuntu I don't have Docker on this machine at all so here we go we need to add the
second all right we're Ro rocket and rolling so uh if you didn't follow the series this is a server that's running Ubuntu um and and we we set up a few Services just running on it but now I'm going to I'm installing Docker and um we will just get a container up and going and then reverse proxy it with caddy so let's run
this cool and then oh so sorry that just updated our package list so that made it so that we can install Docker and now we should be able to install the docker Community
will it's interesting we have to use pseudo to run it though actually I don't want to do that I should be able to add my user to the docker group and then I and then I won't have to run run it with pseudo let's see
uh do I use mpm Serve not sure what you mean by that um it depends on the app that you're running mpm serve uh I see what you're saying there's potentially apps that have those mpm scripts so that if you want to run them in production which which script do you use I think that's what you're asking I talked about this in my last video so I show that you typically don't want to do like mpm run Dev um a lot of times especially even if it's just a static website you don't even want to do mpm serve or mpm preview because you want caddy to be your static file server like nodejs technically can be a static file server but caddy is a lot faster at it um so if you have a site that ultimately is just static files like a react app built with vit or webpack or rollup or any of these things like it's not it's not nextjs that requires a serers side runtime you can just do the build and then run the static app directly with
caddy I think that's what you're asking uh astronotus says you your series inspired me to finally update my VPS I also use Docker with caddy to host a Discord bot so I'm interested to see how you're going to do it nice um yeah will this install the Damon you had to install the desk you shouldn't have to install the desktop yeah so it is so we can actually do pseudo Docker PS it installed the Damon it's running but uh look at me I'm about to I'm going off script I'm not even following the tutorial I want the CJ user to be able to run Docker commands without being pseudo and I think to do that I can just add my user to the docker group so let's do a pseudo pseudo uh user mod we're going to add the group Docker okay I have to look it up because I I actually I guess I could use tldr I
can't remember if it's group name first I think it's group name and then username let's tldr
command okay it is group user uh cool so now that CJ is in the docker group um I'm going to exit my SSH session and when we reload my user is now in the docker group so I should be able to run Docker without being pseudo yes this is what you want I I really don't like having to do pseudo all the time um and especially you don't want to run those commands as roote like Docker is running as the docker user so great and if you miss that the command is user mod AG Docker the group and then the name of your user and then now you can run Docker without using pseudo okay so we have Docker running uh let's just do the hello world I don't think this starts up an HTTP server I think it literally just like spits some stuff out but let's see it's going to pull that image and yeah it just says hello world cool um but let's start up a Docker container that actually runs a website again I'm going off script but I
think I want to run an app that I ran in the docker video that has a reddest databas database and then a node.js API let's do that so I have an app called Pokemon cacher and so this is a node.js API that caches responses to the Poke API in a reddis database and I showed how to set this up with Docker so if you look at the with Docker comp compos Branch I have this Docker compose F actually no this doesn't dockerize the API does anyone know of a quick and easy API like nodejs API that I could spin up that um um yeah do it live Docker eyes the I guess I could do it live I've I guess I've been live for an hour and a half
let's at least get the reddest database running just so I can show that happen and then we'll and then we'll go from there okay so I'm going to clone this repo I'm going to use the public clone because I don't want to set up a deploy key and so over on the server I'm going to go into my host directory and so this is where I have all the apps that I have running and we're going to clone this down and then we'll go in and I need to check out the with Docker compose branch
yeah so I'm on the branch and now we have this Docker compos file so let's just spin up the r reddis database we'll see it happen so it's going to pull that reddis image and then it should start the database nice we have reddis literally running on this server which is pretty cool um so it's as simple as that I I think um as long as you can run docker things if something is binding to a specific Port then you can you can run it you can reverse proxy it so uh we want to set up a Docker file for this I'm just going to do this locally because I want to be able to edit it in vs code so let me get that all set
up cool so uh we're on the with Docker compose Branch let's open it up with vs code and we want to create a Docker file so essentially I have a node.js app here written in typescript and I want to put that into a Docker container uh I talk about it like I'm going to do it from scratch I'm just going to go copy paste so we need a Docker file we need to say which image we're pulling from so I'm going to say from node uh LTS so that'll grab the long-term support version we'll try to do the basics for memory and then I'm going to just copy paste for an existing Docker file um we want to um copy in the package.json so what we need is the docker image needs to have package Json and package. loock so it can then install dependencies so we're going to say copy package.json uh into the directory and before that we need to set our working directory so
we'll say uh worker and then I'm just going to set this to slapp so it's it's going to put all of the files associated with the with the application uh in the slapp folder copy the package.json it's going to then do an mpm install so that'll install all the dependencies and then from there we can copy the rest of the app so we'll do uh copy everything into the SL app so now all of the stuff lives inside of the docker image that's pretty much it um in the start using Docker video I talk about how technically we really only want this in development because uh when we're running this nodejs app in production we technically want to be running this dist folder which has all of that typescript built into JavaScript and so technically we can create a container that only has the built files inside of it so let's let's go do a copy paste so I'm going to grab this repo um I think it's called the backpack
debuggers and I specifically set up a Docker file that has multiple stages inside of it yeah check it out so um we have the base image uh actually I I will talk about this so instead of using the LTS image directly if we use the Alpine image it's actually going to be a lot smaller because the Bas nodejs image is actually built on top of dbn and I think that image alone is like 1 gab but if you use the Alpine image it's something like 2 or 300 megabytes so it's going to be a much a much smaller image and then we're using multi-stage builds so all of this is going to be our base uh image and then we can pull from there so I think I'm going to grab the rest of
this from here and I'll talk about what this is doing so this right here is the base image the base image only has the dependencies inside of it it has all of the node modules but it doesn't have any of the source code then we create a separate image called the dev image this is based on the the base image but now this also has all of the source code inside of it because when we're in Dev we want to have all the source codes with all our configs and everything else so that's the dev image and then you can think about each of these as a as a separate thing that isn't based on everything above it it's only based on the the image we're we're specifically basing it on so from there we have an image called the build image or build build step and this is based on dev so dev has all of the files in the repo it also has all of the dependencies that were installed and so now within the dev container we have the ability to run mpm run build because we have our dependencies we have all of our source codes and then when that command is run it's going to spit it out into this dist
folder and so now the disc folder lives inside of the uh build container from there if we want to create our our production image we base it off of the base image so if you remember the base image only has has the dependencies inside of it and then we copy that build folder into the production image so our production image only has dependencies and the dis folder it doesn't have all the extra source code okay so this this is the docker file that we want and then we want to be able to run this from uh from Docker compose so I'm going to I'm going to save this and then I want to add some configuration to our Docker compose so right now our Docker compose only has the database service we also want the app service and we will say just build the current directory so it's going to look at that Docker file and it's going to build that and then we need to give it uh a few other settings to specify that it should use the prod image here let's
compose so here we're saying um Target that prod step from the the docker file and and use that from the docker file so let's just copy
this we should be good to go so we have our prod image and so specifically in our Docker composed because we said use this it's going to run through the build and finally it'll do this build step but now this is the image that will be used whenever we're running it uh we need to expose to Ports so uh 5,000 seems fine I'm going to go aad and change it to something I know is not going to be in use we'll change it to 7,000 actually we'll use the uh Port environment variable so whatever we specify in the EnV that's what it's going to expose and then uh right here we'll pass the port environment variable in and then for this app we also need the reddis connection information in in our environment varibles so um essentially these two values here need to be specified so that it can connect and we'll bring this in from the
EnV okay we're running in production we have our Port we have our host for redus our port for redus uh we have it that it depends on the database which is our our reddest image here I think that's I think that's all we need I I guess I can technically I can run it locally just to make sure it works before we push it up so if I do a Docker compose up I need to start up a Docker engine real quick and I'll catch up on chat because I did a bunch of stuff um am I going to run Docker init I have not run a Docker init before does that create a Docker file yeah I saw that too there is an app uh someone created that will you just tell it about a thing and it will dockerize it uh I guess which which is relevant because I've been learning about kify and they use a thing called NYX packs and this is a project that uh tries to automatically we're getting blinded here uh tries to automatically figure out what your app is and then can
run it inside of a container so I think yeah this has support for so many different languages and it can automatically containerize them so that's that's another thing that we can use node is built from Alpine anyway it's built from Debian and I only know that because in the tutorial I accidentally used that and it was like a gigabyte for the image yeah what's up Levi yeah thank you H I was wrong um shouldn't the last one based on dev not the Bas image or am I wrong let's talk about it because uh I think I'm right but um the last one is based on the base image so from base which means we're going to get all of this the only thing we're getting from the build step is specifically this folder here so because we say from base you can think of it as an image that only has this here and then we're copying files from this build phase but those are the only copies files we're copying is from
build and actually I I made a mistake here because this is outputting to the dist folder not the build folder so this actually needs to be from oh no no no here okay never mind so from the build step copy the disc folder into app yeah hope hopefully that clarified things uh Cody says shouldn't build images on a cheap VPS or server you can run out of memory build and push to a registry yes I mean um for this it should work I mean even the VPS that I'm running here I think it has like two gigs of RAM and two CPUs it's pretty small um so it should be able to run this but for anything bigger yeah you're going to run out of memory but I think we should be good yeah uh why is Alpine not the default there's some things that just aren't built into to Alpine or that you might need from the dbm images versus the Alpine image okay so this Docker file looks good our Docker compose looks
good let's try it uh I need to make sure that my EnV has all these things so the EnV also needs the port variable and I'm going to set that to um 7,000 and actually we'll do it both ways because the port inside the container is going to be this and then we want to expose that port to that same port on our machine so I think that's what we want let's see Docker compose
up okay so it's right now it it's pulling the DB image and then also it's build building the nodejs image so it did the mpm install nice yeah only thing is my application code is saying hey you don't have a reddis username or a reddis password so I think I just need to make sure that I pass these in as well even though they're empty because by default we're using reddis in insecure mode so it doesn't have a username and password but we'll just we'll still pass them in but they're going to be empty when they get
okay so I'm going to kill that restart it um cool so it's trying to connect to reddis but in my dnv I said it should connect on Local Host that's not the case anymore because um we actually want to connect to DB in inside the container because a local host inside that container actually means that container uh I want this value to be DB so that way it connects to the um the reddest container because Docker creates a network and then internally to this node image here DB is going to resolve to the IP address of this container over here all right first try third try but we do have an app running on Port 7000 and I think if we go to API V1 Pokemon and then a Pokemon name like Pikachu yeah so this this is actually caching that uh via the Pokey API and if I refresh it should be instant cuz it's it's now pulling that from the redus cache okay we're good to go got our Docker fire we got our Docker
compose I'm going to push this codes up and uh then uh try building these images on the server it will be interesting to see can my server handle building this node image um but let's do
okay so I push the changes up and honestly you're kind of seeing a manual workflow of if I made changes to a repo and that repo exists on the server here um as long as I'm on the right Branch I can just do a get pool and I have now manually synced the changes to the server here uh but now that we have that let's uh update our EnV I'm just going to copy what I have locally and no andv is going to be production and let's start it up okay so it's pulling the reddest image and the Alpine image actually I mean while while all of this is happening let's let's ssh in and we can do a a top you can see that even SSH is slow right now we're at 67% memory usage um but if you you do top you can see all of your processes so yeah my CPU right now with this build and pull is at
78% and um I only have 648 megabytes free of memory so this is why you want to build server because if I had actual users using my VPS while this build process is happening everything slows down like all all of the other processes on the machine have less resources um that's a thing for sure but once this finishes you should see this CPU usage drop way down because it's it's done with the build and then it's just kind of like idling there but yeah building a typescript app 70% CPU
usage yeah I mean you can tell this server is not great it took 42 seconds to install the npm depend all right so now it's running our CPU yeah so now now that it's built everything it's running in the background CPU usage drops ways way down because it's literally just idling there right so this thing is running now on on Port uh 7,000 and we're good to go but at this point now because the app is running we need to set up a reverse proxy right we don't we don't have any way of accessing Port 7,000 so we want a reverse proxy um so let's go set up a DNS record I'm gonna hide my screen for just a
Create Caddy reverse_proxy to a docker container
okay all right we're back uh I want a a another a record here that points to my server so that way I can reverse proxy to that specific domain so I'm going to add a record it's going to be an a record we're going to call this Pokemon
cacher and we're going to point it at the IP address again I could use a c name here I'm just going to do the IP address load TTL save it and then we also need a dubdub duub record so uh if someone goes to www.pon cacher doot looc host.net we want that to redirect without the dubdub dub uh and so we'll use a c name here so this this is a scenario where hey um when you go here I want you to resolve the DNS here like this so uh that points to pokemoner dolal host.net we look up that record and that points to the IP address so this should be good to go now that we have the DNS records we need to set up a caddy config that uh will specifically work for for these websites so uh I'm on the VPS let's go to uh Etsy caddy and then I want to create a file
inside of uh sites available um so technically I don't I don't need to be in the folder but what I do want to do is I want to copy one of those files like the when we set up the apis it's it's going to be ex almost exactly the same so like if we look at this holidays API it is a reverse proxy listening on a specific Port it'll show any errors that pop up and it's going to redirect dubdub duub to the the root subdomain so I want something exactly like that so I'm just going to copy this file so I'm going to copy holidays and put that into Pokemon
cacher cool and uh now I'm going to edit that and I specifically want to set the domain here so the root domain is Pokemon cacher we're going to reverse proxy it to 7,000 because that's the port that we exposed from the docker container and then we're going to redirect dubdub dub. pookemon cacher notloc host.net into uh Pokemon cacher loal host.net cool this should be all we need so we'll we'll uh oh dang it I'm not pseudo I thought I was
um there we go so pokemon. loal host.net is a reverse proxy to Port 7,000 which is where we have that Docker container running and we're going to redirect dubdub duub to the route this should be good uh now the way we have this set up I want to link that file from sites available and sites enabled so let's do
this and we'll change the file name so we want to create that file called Pokemon cacher and it's going to be from the file called Pokemon cacher great so if we look in sites enabled there is now a link to that file if we reload caddy the reverse proxy should be running and that should proxy any requests that come into Port 7000 to the thing running inside the docker container so let's do it uh pseudo service caddy reload all right let's give it a go if we go to Pokemon cacher doot loal host.net it's working so it is reverse proxying these requests into that Docker container and if we go to API uh V1 Pikachu uh oh Pokemon
Pikachu yeah good to go and uh we can see in the logs yeah other people are coming here people watching live are coming to the site as well uh I'll give you the I'll give you the link here caddy time yeah
um honestly I'm going to make the executive decision yeah I I will I will mod you Stony Eagle we we know Stony we trust them and they're on Twitch a lot so please uh use use your your best judgment to moderate things thank you Stony but uh we're good to go and so I mean really the the main thing I kind of wanted to show here oh you got Bulbasaur bulb oh you spelled it wrong you're missing an A in Bulbasaur um but the main thing I wanted to show is as long as something is running on a port no matter what it is it doesn't have to be a node app it could be inside a container it could be a go app or whatever else if it's on a port we can reverse proxy it through caddy and so use what you know about Docker to I better not show these logs people are uh um no actually so here's the other interesting thing I'm actually I'm killing the containers now and this is one thing I should actually update so I'm killing these containers once the container is down we're going to get a bad gateway right so the container is no longer running and exposing Port 7000 if
we try um going to it again bad gateway right so caddy is trying to reverse proxy it but the thing isn't running on on Port uh 7,000 there's nothing to respond to those requests now one thing you want to do is if you're going to be using Docker compose in this way um is you actually want to set to restart to always because if this server were to crash it would just stay crashed and so there's actually a setting in uh Docker called restart I think you can do it like this always and that way if this thing ever crashes it's going to automatically restart and so you get a similar experience to something like pm2 where it auto it manages the process uh let me make sure I'm specifying this right right uh
policies restart no I think I did that right so uh when we're if we are going to be running this in production like this and I wouldn't recommend this for big sites for for bigger sites you're going to want some kind of uh con container orchestrator or something like that but if you are going to be running Docker compose restart always at a minimum and then you can do a compose up- D and that'll run it in Damon mode or detached mode um and so now I I still have access to my terminal here but I can see that these Docker containers are running and I shouldn't get a bad gateway anymore yeah so now um the the API is running again cool cool I'll answer any questions you have in chat and then we'll uh we'll keep moving yeah I thought you had to create a whole network no idea you could just say DB uh I do believe Docker compose creates a network for you so you don't you don't have to uh
or I know that you can specify custom networks down here but by default all of the services listed in a Docker compos are going to be put within the same network so that's that's definitely why that works um can I share my bash RC aliases I actually just I use zish I use zish now and it's pronounced zish not Zell but if you check out my my DOT files um I think I I updated these yeah you can see my zish RC and uh I just have a few aliases these I don't use as often but I use these these get commit aliases pretty often uh technically you get some aliases when you enable the git plugin in zish I know I'm triggering people by saying zish uh you get aliases but these are some aliases I got used to that aren't aren't built into the to the git plugin uh but yeah you can see all my DOT files here what's up Murdoch welcome in uh can
you give 00 Z instead of Local Host no because 0.0.0 also means the container itself so the way to think about that is uh app is literally a it's a Linux computer it's a container but about it as its own computer and if it references Local Host it's always going to be referencing itself and so 0.0.0 technically is Local Host as well it's just referencing itself we need to reach outside of this container to this other container which is why we need its IP address now uh it's possible to get the private IP address and you could actually specify that but this is just a nicity of of Docker and Docker composes that it you can use this host host name and now internally in this container you don't need to know the IP address yeah is Bulbasaur no uh you you have to I'll show you how to spell Bulbasaur uh Bulbasaur like that yeah there you go
Bulbasaur is a Pokemon um restart the db2 yeah you technically can do that um you're completely right I kind of just trust it to run because because it is I mean I say that but yeah you're right we probably should have restart always on the on the database as well yeah yeah thanks Tony I I did mind you I don't know if you're still still sticking around um cool anything else anything else all right I think we have just a couple more questions and then we'll get out of
here yeah uh we talked about cicd and we just talked about Docker and again all I wanted to show you is as long as something is running on a port whatever that is you can reverse proxy it through caddy okay and uh this is this is related so uh sirge is saying awesome video uh can you use caddy as a reverse proxy for Docker containers yes so exactly like I set up you don't have to do anything special as long as the P Port is exposed you're good to go and X samon says uh it would be interesting to see if we can automatically link running apps in Docker to caddy ports this could eliminate the need for explicitly mapping ports in the reverse proxy setup there is a project for that so imagine this you have a VPS and you have a bunch of Docker containers all running on a specific port what if you could add a configuration tag in your Docker compos that specifies the domain name and then you have something listening for that and if it sees that a Docker container exposed a port and it has that tag it can automatically add the caddy config that
Docker automatic reverse_proxy with Caddy
exists that exists so there is um this tool called caddy Docker proxy and fun fact uh kify is actually using this under the hood um but the whole idea with this is it's running in the background and then you can add tags to your Docker compos files uh label you have they're called labels so for example this uh service has a a caddy label of Who Am i. example.com so that's automatically going to create a a caddy configuration that points to that domain and set up SSL and everything else and then all of the properties in supported inside of caddy files can be specified in this Docker compos as labels as well so this is a reverse proxy to this Upstream on Port 80 um and it basically supports all of the cad file syntax but has like this nested dot syntax you can see a bunch of examples of like how how you can specify the tags versus how it
gets translated into a caddy file um and so this makes it super convenient so you can just set up all your Docker composes with the correct labels and then you don't have to manage separate caddy files it's all done from your from your Docker composes and like I said uh coolify is actually using this under the hood when you when you enable the cad proxy they have this package running behind the scenes and that's how you can customize things in your coolify dashboard as you uh update these labels so yeah that's a thing uh can you use emojis in the URL uh you can try I don't I I the server should be able to respond to them you just have to handle it yeah oh sorry about that Stony all right let's keep going um yeah caddy Docker proxy check it out hi hiker sloth says uh great videos thank you so much I have watched both and worked through first on my own VPS we'll be working through this one as well I would like to set up uh some of the other Dynamic websites like nextjs
Self Host Email Server
and Ruby on Rails also would be interesting to see how an email server could be set up so I'll touch on this quickly because I'm not going to get into like how to set up an email server but it is possible to self-host your own email server the the issue comes down to uh IP address reputation because um the there there's so much spam when it comes to email that some of the biggest providers like Gmail and and any other like big email providers um they kind of have a big say in what IP addresses are valid or not and there are uh lists published that that certain um email servers can uh subscribe to that say what bad IP addresses are coming from or basically IP addresses or IP address ranges that see a lot of spam emails so when you are attempting to set up your own self-hosted email server you need to make sure that the IP address that you get is not within these bad sub
ranges and is on a VPS provider that hasn't been um specifically marked as like spam or whatever else so that's one thing you have to look out for but if you've done all of that you make sure you have a good IP address there's some stuff for it so there's this thing called Docker mail server it has everything you need anti- spam antivirus SMTP all of that uh ready to go go in Docker containers and it includes all of these all of these services that you need so that's one way another one is called mailcow and it also runs through Docker so they have all of the the possible services that you will need to get it up and going there's also a thing called mail in a box and then if you want to create uh like a transactional API email server postal is an open source way of doing that so if you've ever worked with like mail gun or send grid they let you send emails via an API post tool is a way of doing that so hosted but again you have to think about IP address uh reputation the other thing you have to think about is uptime right so you don't want your email server to
go down because then you potentially lose emails now there's redundancy built into the like Mail system where if email delivery fails it'll potentially try again but you might actually lose emails if your your VPS hosting your mail server ever goes down so hosting a mail server should not be done lightly uh there's definitely a lot you have to think about but there's there's some tools that uh let you do it fairly easily uh would you trust your own email server maybe browsers remove the Emojis because it's a security risk oh fascinating well there is a um there's certain top level domain names that actually support emojis in the um um in the URL would I make a video for selfhosted email probably not just because of it's way harder than you think like I even so I I did this like there are certain hosting providers where you can
buy like let's say like business hosting and they provide an email inbox and that way you're not managing the mail server but they give you very similar to these hosting services that give you like a c panel dashboard but in this case I bought one that had um a mail inbox provided on it but for whatever reason that very popular hosting provider all of their IP addresses had been marked as potential spam so no matter what I did even though I didn't set up the server manually I was just like using their mail server setup no matter what I did all of my messages got marked as spam uh it's a whole thing there's actually like one guy who maintains a Spam list and he he like exploits people there's a whole thing like if you get on this list then you have to like pay him to get your IP address off of the list I don't know but uh ultimately what I did is I used that as my email inbox cuz receiving emails is fine like servers aren't going to complain if your IP address of a mail that that they're of a
server they're sending mail to is on a list they only care if they're receiving mail from that IP address so what I ended up doing is that's my email inbox manager so that's where all the mail comes to and then if I need to send emails I use uh AWS uh simple me messaging service to actually send those emails yeah use Gmail and Cloud flare cool uh would you make a video for self-hosted email but yeah I I don't I don't think I would all right let's keep going uh next message comes from E Cognito it says good instructional content I skipped through to see if I could pick up any tips especially on caddy which I've been using for about a year gratified that I organized things in Etsy caddy in a similar fashion I want to do this very quickly but one thing I want to show you is another way of managing caddy files that isn't this idea of creating links in sites available and in sites enabled and um I actually figured this out like I I I researched it when I was making
Manage Caddyfiles with a single folder
the video but I didn't end up making any sort of update but this idea of sites available and sites enabled it actually comes from the world of engine X that's where I learned it because I have a lot of experience with engine X um but they in more recent editions they actually deprecated it and they say well we don't want to do that anymore just put everything in a conf. d folder um and there's a couple of overflow posts that I'll link here that talk about how uh some of the things that could could go wrong or that you could do wrong if you're using the sites enabled and S sites sites available uh way of doing things so let me show you actually an easier way so uh and just to to recap we have at the root here a caddy file that caddy file says import everything from sites enabled so if we go into sites enabled and list this here all of these these files are links to sites available so if I ever want to bring a site down I
actually delete the link in this folder reload the cadd service and then because that file isn't there anymore that service is going to go down um and this is nice because you don't lose your settings right because if we go into the sites available folder this has all of the actual files that live here so if I delete them from sites enabled I'm just deleting the link I'm not deleting the actual file and so that that's one way of managing it but let's talk about another way and let me show you how to set this up so uh what you could do is just have a single folder and call it like conf. d so a configuration directory um so let's drop down to a a root
shell okay I'm in a root shell I'm going to create a directory called comp. d uh I'm going to copy all of the files from sites available into comp. D so we're just going to do copy sites available slashstar into comp
dstar like that okay so now if we look in comd it has all of those same files great but one thing we should do is uh we're going to put a file extension on all of these files uh so that way we'll only look for files with that file extension so I don't know a way to do this in bulk but I'm just going to do it manually so every single file I'm going to rename it to that file name do caddy
okay so at this point all of my files have the catty file extension so what I should do is in the main caddy file instead of importing from sites available we're going to import from uh comp D instead so if we edit that caddy file down here at the bottom instead of importing from sites available we'll import from compd and we'll add do catty file on the in here so any file. catty file should be imported okay so at this point really all we've done is we've we've moved everything from sites available into compd and now catty file is looking at those and so if I just do a pseudo service reload or service oh we're already rout I could just do a service caddy reload it didn't complain U my sites should still be up I should still be able to go to not local host.net yeah that still
works and like Pokemon cacher still works cool so caddy is still reverse proxying everything everything still works just fine uh and I mean to prove it let's actually just remove well I'm not going to remove them I'm going to make an old directory and I'm going to move sites available into that old directory and sites in enabled into that old directory okay uh but this is a lot easier to manage because now you just have a single folder so anytime you need to create a new website you put it in this folder and if you ever want to disable a website you literally just move the file so if I want to disable Pokemon cacher I'm going to move Pokemon cacher to Pokemon cacher do disabled and now that it doesn't have the catty file extension it's not going to be imported into the main config so I'll do this that's there I'll reload caddy and now Pokemon CER should be down yeah so this site just doesn't
doesn't exist anymore in the caddy config um and that's just because I renamed it to disabled and then if we want to enable the site we we remove the disabled uh file ending like this and then reload and now the site works so honestly this is a a much easier way to to manage all of these files cuz you're not like managing Sim links and one of the things that that stack Overflow uh post talks about that all link to is like a lot of times some system administrators didn't understand the system and they were creating files in the sites enabled folder when they should have created them over here and it was just a mess but now if you have a single directory and you just use the file name to disable the files it's a lot a lot easier to manage so that's what I would say you ultimately you can do whatever you want and when you look at the caddy documentation they don't even have a preferred of doing this right it's kind of up to you how you manage all of your caddy files um but I personally I do like the the conf D way
of doing it because it's just less to manage yeah U mad says yourself host 101 series really help me oh that's awesome glad to hear it yeah I will do that uh uh Haku thank you find exec move uh yeah we could have figured it out yeah the caddy config is very instant for um awesome all right I think I only have a couple questions left yeah in this case suggestions for next time and it's really just talking about what I've what I've already mentioned before so uh belachi mentions are you planning to make a video about hosting a node app in in on VPS like hetner and kify would love to see that and W salom says I'm very curious to see kify in action yes I'm working on it now it probably won't be out this week but I'm hoping to publish it next week while I'm away at uh react Miami um but yeah
Suggestions for Next Time
the next video is on kify and ultimately I want to make sure that I I have enough experience with it at this point I've been messing around with it for like about a week a few days and I just want to make sure that I figured things out and I I can relay all of that to you but yes the next video will be on coolify where essentially instead of managing your server manually from the command line like this you can do it all from a mostly from a from a web UI yeah um and then jit X is mentioning uh I have a request please can you create automatic deployments and preview deployments on push to GitHub uh for full stack apps that would be just awesome yes and this is something that um kify supports so once we get kify up and going um they have this idea of preview deployment so if you've ever used versel they have this where when a a pool request gets created if that user has the right privileges it'll create a deployment that's specific to that pool request that way you can test out the features and coolify has support for
Preview Deployments with Coolify
this now again you could do it manually like we talked about earlier um about how to have web hooks you could write a custom script that like spins up a caddy file based on the branch name it's possible to do manually but coolify has it built in um so that's pretty slick as well I will mention I'll link to this uh tweet that I made yesterday uh I'm still working on the coolify video so if there's any specific typ type of app or stack that you want to see me get up and running uh let me know in the comments of this tweet um because I'm trying to find things like I'm G I'm GNA definitely do like a nextjs app and probably get like a postgress database up and going some of the more common things that people do so I just want to know what you're interested in definitely respond in that tweet uh Mike the tree climber says so caddy is like inine X yeah exactly um in the self-host series um yeah in this one probably 15 or so minutes into the video uh I talk
What do you want to see hosted with Coolify?
about how it's similar to engine X and traffic and Apache HTTP D um yeah caddy is basically a a web server but very easy to configure and very very minimal to configure do laravel I also don't need a build step yeah people have been mentioning laravel ultimately if I can't find like an open source laravel I mean actually coolify coolify is built with LEL um it'd be very interesting to deploy a coolify instance with coolify but I might get like the uh just a plain old laravel app up and going like generate one and then show how to deploy that but yeah that is coming up next okay um Adam CER who we saw in the chat earlier uh is asking about build server so uh a great video yet again CJ I've recently been playing with kify on header to host my own database and analytics I did try deploying my personal site but I have some image resized in ETC as part of the build
Coolify Build Server
process and it's pretty CPU intensive and caused other issues and other servers to go down so this is very similar to how earlier when we were running the uh Docker compose up it had to build the images and we went up to like 70% CPU usage anytime you're running a build on your server you would potentially have to worry about that so would love to know how to handle situations like this and tips on caching great video yeah and then Jake Hill says now we need a video on docker plus caddy is setting up a remote build server so that's what I'm going to point you to because um coolify actually has this idea of a build server built in so once you get kify up and going you can configure a separate server install kify on it and designate that server as the build server and so anytime kify needs to perform a build task it's going to do it remotely on that other server and then copy all the build of the build artifacts back to the main kify server and that's basically how you manage this is you you just need a separate service that is doing your
builds instead of the main VPS itself I talked about earlier like GitHub actions that's another way to do it essentially instead of spitting up your own build server you're using GitHub actions as your build server so that's a possibility as well uh but it is nice that kify currently has experimental support for build servers all right that's all I have uh I'll catch up on the chat and then we'll just do a quick plug for centry what is coolify exactly think of it as like a self-hosted Heroku or a self-hosted uh versel basically you can run it on your own server and get a very easy like oneclick deploy like experience instead of a build server you could use your local machine that's another way to do it so kify has this idea of like Local Host and remote servers so like yeah technically you could you could have it running all the time on your home machine it could detect changes probably through like a a cloud Fair tunnel or something like that run the build and then push it to like a remote coolify instance that's
definitely possible yeah cool and thank you FD thank you thank you thank you for the heart all right um yeah let's do a plug for centry so uh syntax is brought to you by centry if you're not familiar with it visit sentry.io um they are an application monitoring uh softwares so you can add it into your backend codes into your front end codes and then anytime an error happens in production you can be a of it and it does a nice grouping of Errors so you can see how often that error is occurring and you can see stack traces like full stack stack traces so if you have sentury installed in both your front end and your backend you can very easily uh see like when an error occurred and kind of like follow it from the front end to the back end and um they show you how many users are coming across that error so it's just really good to have some insight into your app that's running in production they have a bunch of other features too so they also have a
Brought to you by Sentry
performance monitoring feature so uh um you don't even have to do anything special for this like let's say you want to uh see the performance of your database queries cry will automatically detect slow queries so it can it'll show you in your dashboard all of the database queries that are happening how long they take and then you can very quickly see oh this this query is using or is is taking four or five times longer than my normal queries and they also can detect like in plus1 queries and stuff like that so once you're is running in production and users are using your app you can get a much better idea of which parts of the app are getting hit and which parts you need to do performance tuning on there's also a session replay you can see exactly what a user was doing when an error occurred you can also get alerts when error occurred centry is awesome um one thing I'll point you to is a self-hosted Sentry so you can use the hosted Sentry option they also have a a very generous free tier but if you want to self-host it you can since we're talking about
self-hosting on your own server so they have a whole set of documentation on how to get it running on your own system they talk about minimum requirements as well but uh you can self-host it on your own server you could have your status page on your own server you could have all of your databases and apps running on your own server along with century and uh get alerted when when stuff is happening there as well so definitely check out uh sentry.io and uh check out self- hosted if you're interested in getting that up and going so yeah could you uh Phil is saying could you explain the difference between infrastructure as a code tools like terraform and palumi versus configuration tools like anible and machine images like Ami I don't have much experience at all with these uh what I would probably say the biggest difference is infrastructure as code potentially has the ability to automatically provision new resources like it could spin up actually spin up its own a new VPS P purely from configuration because like it has uh Integrations and plugins
with like the AWS API and and like the Google Cloud API and stuff like that so you can have a a terraform configuration that uh literally spins up these instances whereas as far as I'm I could be wrong here but I but I do think anible is more so about okay once you have an instance up and going here's a set of configuration to run on that machine don't quote me on that but I think that's a good place to start is this stream sponsored by kifi no it's not no it's not yeah and green thumb says I love to see love love what you've been doing with thank you green thumbs uh and srg says I miss your Avatar mini games in chat we'll eventually once we get more live streams here on the syntax Channel we'll figure out mini games and stuff like that all right I think that's all I have for you this this was this was my first live stream on syntax I I had a good time I I really do appreciate everyone for for hanging out and uh asking your questions they were great and please keep asking your questions so um with without you it
Thanks!
would just be me it would just be me making videos so I appreciate the comments that you make I appreciate the questions that you have and keep them coming so so on on any of the existing videos as well I'll I'll go ahead and link to this series cuz this is what we've been specifically been talking about today on any of those videos if you have questions I'm checking the the comments often and um answering anything things that might come up and we've got uh at least one more video on kify coming up in the series as well so uh srg says you're a beast of live stream oh thank you srg all right that's all I got for you we're going to get out of here this was fun hopefully we can do it again soon and uh again thank you everybody for tuning in thank you for your questions you're great you're awesome stay
Quote it with credit and a link. Quoting Syntax