Kutt.it is a free open source, self hosted Link / URL shortener to replace Bit.ly and others.

Kutt.it is a free open source, self hosted Link / URL shortener to replace Bit.ly and others.

10.Aug.2021

it's your open source advocate and i'm
back with another video
this week i wanted to talk about url
shorteners so if you've ever used
something like bitly bit.ly
or gu google
i think it was go.gl
those things basically take a long url
that you have and will shorten it into
something
much smaller so that you can post that
on things like twitter especially back
when twitter only had 140 character
limit
um this makes just makes links a little
bit smaller and then it keeps a database
of those links that are created and
where they forward to so when you click
on that link it goes to the site that
you created the link from
looks in the database says oh yeah
that's where you want to go and forward
you along to
to that url so these are really super
useful
tools and you can self-host some of them
as well so
one that i was asked specifically about
is cut.it so
if you go to this page you may get a
certificate error
i went ahead and went through it when i
got that i think they just let their
certificate expire but
it comes up and you can see kind of what
their their demo site looks like here
and you can use this site but you just
never know how long it'll be up or
if the certificate expire if it will
even function correctly so that's one of
those things to kind of keep in mind
but so right here i can just type in
https colon slash slash
show notes dot open source is
awesome.com
so this is a fairly long url and it
takes up quite a few characters it's not
the longest one out there but
especially if i wanted to forward you to
a specific
uh one of my pages there
so my main page here with opensource is
awesome.com is already pretty long but
then when you click into
these different things so for instance
this one this is a really long url
so i could take this url and i can just
copy it and i can go back to cut.it
and i can just paste that url in there
and then i can just click on the little
arrow button or hit enter
again it's got options for advanced
options as well
um if you have any so if you want to use
those you have to get logged in
so it tells you that right off the bat
and then they've got some some charts
and things like that where you can keep
track of short urls but
the main function is to create a short
url so if i click on this
it's going to go through and here you go
so this is much much shorter than what i
just pasted in there
and then you can click this little
button to copy it and now i can just go
paste this in and i can move
right through it and it should forward
me right to the site that i want to go
to which
is this post so this is what a url
shortener does it just makes a really
long url into something really short
that somebody can click and just
move through this to the system to to
whatever it is they're trying to access
before i get started today i want to say
thank you so much to my patrons over at
patreon
you guys supporting me and letting me
know that you appreciate what i'm doing
just really means so much to me and it's
hard for me to put into words but i
really truly appreciate that
and and i just thank you so much and i
want to say thank you to the subscribers
and everybody at youtube who's watching
my videos and liking my videos i truly
appreciate that
so if you haven't already done it please
subscribe like
share this with your friends so they can
come along on the journey with us and
we're going to do some really great
stuff i've got some great videos coming
up
i'm working on some stuff for free ipa
which is kind of like active directory
but free and open source
and my goal there is not to just show
you an option for active directory but
to show you how to put a lot of the
stuff together that we've been using
and in particular things that they can
use ldap authentication so you can
really set up a single sign-on situation
i've had requests from folks to make
things that are like office
suite type software that's open source
and self-hostable
and then things that might be for a
university and so on and so forth so i'm
going to try to give you guys that
that information i'm going to try to
make it in a way that is really easy for
you to kind of take that information and
take it and use it in your own
situations that's always my goal
of course and i know things don't always
go the way you want them to but i'm
going to do my best to make it that easy
so i hope you'll stick with me while i
get that stuff ready it's going to be a
series of videos only because it's
so much information there's no way i
could stack it into one video
you'd lose your mind i would lose my
mind so i'm going to stack it into bits
and pieces so that we can all go along
one at a time and you can kind of take
your time and do these things as you
have time
i'm going to try to break it apart in
pieces where i feel like
this is something where i could do this
much and then stop and come back to it
and pick up where i left off pretty
easily
because that's what i want for you guys
because i know you don't have all the
time on earth either
and it really just you know it makes
sense to do it that way so i hope you'll
be with me for that and enjoy it
and i've got lots more little tidbits
like this one here which is a nice bigly
replacement
thanks for the suggestion on this one i
really appreciate it i love when you
guys give me suggestions for things to
go look at
i know sometimes it takes me a little
bit of time to get to them and make the
videos on them but it's because i'm
going out there and looking at them
and i'm just getting a feel for them and
i'm learning about them and i'm trying
to figure out how do i do this in a way
that will be useful for you
so give me give me time be patient and
i'll try to get around to all the
suggestions as
i get a chance but really i appreciate
that now let's get started on this
install
cut it is not super difficult to set up
or install
there are some caveats that i want to
talk about as we go through it but
really overall it's it's not terrible so
cut
cut.it is the main page but you actually
want to go out to their github page
so i'll open that in a new tab here and
you're just going to use git
to clone down the repository you can
just get the docker compose file
and the environment files that they have
here
if you just want to try to pull those
down but it's just easy just to pull
down the project
so i am already logged in
to a server where i have it pulled down
but i'll show you exactly how to do it
so you type in git clone and then just
put a space
and then from here up at the top of the
repository you click on this little
arrow
highlight this section or click on the
copy button and then go back to your
terminal
make sure it copies when you do it and
then just ctrl shift and v like victor
to paste it in
and there you go now when i hit enter
it's going to try to clone this down but
it's going to tell me
that i've already got the folder but
when you hit enter it'll clone it down
and create a folder called
cut and if i cd into cut so inside the
folder this is what you're going to see
and there's a few files here if i just
do ls you can see there's a lot of stuff
but right here
you can see there's a docker
compose.yaml file but you need to look a
little bit deeper so we're going to do
ls
hyphen a and that's going to show us
that there's some
hidden files in here so you can see the
ones with the dot in front of them now
these are what they call hidden files
and here i have this.env file well this
wasn't here by default so if you've just
downloaded this this repository you
won't see this file
but instead you'll see this file that
says docker env
so all i did was say cp.docker
dot env and then i took that and i
just copied it to dot env like this so
i'll create dot env1
and then i'll clear and i'll do ls-8
again and now you can see i've got this
env1 file so it's just a copy of the
docker.env file
so this is an environment variable file
that we're going to need in order to run
cut.it so let me just remove that env1
file
and i'll kind of show you what the
actual env file looks like
if i type it correctly it will go away
there we go
so now i'm just going to do nano.env
okay there's a lot to go through in this
dot env file so the first thing is the
port that it's going to run on which is
3000.
i did not change almost anything in here
except for a few
items and i'll talk about those so it
says site name so i put osia
open source is awesome you can change
this to whatever you want it to be but
if you put spaces make sure to put it
inside of quotes
default domain so i actually went and
purchased this domain just for this
little experiment and i made a really
short one so osia.me
is my domain i own that domain sorry i'm
tapping on the mic
um osia.me is my domain and i own it
so as we move down i i change this to
seven so it can put seven characters
after the the osi a dot me
so you'll get some you know for your
short link it'll look something like
this
um o s i a dot m e
slash you know k y two
or three two four l
g so that would be seven characters so
that's about what it would look like
so when you change that number if you
were to change it to six this is what it
would look like five
four and so on but as you change that
down you lose the amount of
randomness and the number of urls that
you can create
so setting it out to seven with the
whole alphabet and numbers
gives you quite a lot of urls depending
on how many you're planning on making
short links for
so here i didn't really change anything
i just left it as postgrass
i did not change anything in these
sections so so just be aware of that
i left this as localhost and i left all
of the information that they put as far
as username and password for the
for the db um i didn't change the redis
host or port
so so continuing down disallow
registration so if you don't want to
allow people to register you can change
this to true and it will
it won't allow them to register on your
site but if you want them to be able to
register and create an account and stuff
like that
you want to leave this as false so that
it allows registration
disallow anonymous links so if you want
to force them to register
before they can create links then you
would change this to true
and then they would have to register
before they can create links again i
just left everything at the default for
this part
user limit per day 50. so each user can
basically create 50 links a day
if you want to change this you can to
500 let's just change that to 500
and then so there's a few other settings
here so
the non-user cool down
so basically you can set this to a time
and it basically makes them wait before
they can create another link so
they don't just spam your site trying to
create a whole bunch of short links
so setting zero to disable otherwise you
can set it in minutes and you could say
if they're not logged in as a user you
know how many minutes they have to wait
before they can create
another set of links i just left it on
zero for now
maximum number of visits for each link
to have detailed stats
so five thousand i don't remember if i
changed this it might have been 500 i
don't know
but it does keep statistics so just set
that to what you feel like and you can
always come change it and then restart
the process
custom domain use https false
so you could say use https for the
custom domains that they're that they're
doing
i just said leave it i just left it
alone i didn't mess with it
so here you just need to enter a
passphrase to set up your jwt
and it's it's use a long and secure key
so just use you know write something it
doesn't matter as long as you can come
look at it later it's fine
just use a upper and lower case so
and some numbers and just mix it up
there you go so that's a pretty long
password it's just a secret it's nothing
that i'm going to use that i'm aware of
so make it really strong so here you set
up admin emails so for the emails that
register
what emails will be set as admin users
so this is kind of where you do that
there's nothing in the user interface to
set this so you need to make sure you
put it here
if it's just going to be you put in one
if it's going to be you and other people
put them in like i did with two
different emails with a comma in between
them
and then if you're going to use google
cloud api you need to put an api key i
didn't do any of this stuff as far as
google
google analytics or any of that stuff so
i just left it all blank if you want to
do that you'll have to kind of go get
your own keys and set everything up
and then finally the email part so if
you want to allow people to register
you have to have email set up and
working
so my email is through mail in a box
which uses
start tls which is the newer form of
encryption
and it runs on port 587 unfortunately
cut.it does not support start tls
so it didn't work for me you need you
need something that supports ssl based
encryption which is port 465.
so i've put a little note here this
needs to be
you know 465 and ssl so 587 doesn't work
i tried it
it would not send the the email no
matter what i did so
this just isn't working as far as this
goes but i know that it's set up
correctly
so this would normally be what you need
so once you do set up your email
information though
you would put your email password here
in this space so that you've got
your email smtp your email host
which is your smtp server basically 465
should be here
this should be set to true now if you
have an email server that will send off
of port 25 and you want to set this to
false
it should work as well but it's just bad
practice these days
and then you need to put in the the mail
user so if your username is not the full
email address just put in your username
here
and then your mail from this would be
the email address so in my case they're
the same because the username and the
email are the same
and then finally again your password
that logs you into your email or allows
you to send email through smtp is what
you would put in this space right here
then this final bit is just the email
address that will receive
submitted reports so if there's reports
and you want to email them to yourself
put in the email address that you want
to receive those things
and then subject email to show on the
app
or support email to show on the app so i
don't have a support email so i didn't
put anything
this is what you would type in here if
you wanted to add it
so i'm just going to change this i'm
just going to set this
and save it and then we'll take a look
at what it does when it runs
so all right once you've saved that file
so you use ctrl o to save and then hit
enter to make sure it's got the
env name and then control x to get out
of nano when you get into the docker
compose.yaml file there's a few things
that we need to cover here real quick so
this is the image that we want that's
great you're really not going to change
much there's only a few things that we
need to look at to change so first is
the ports if you have port 3000 on your
host
already being used you need to choose
another port for it to run on
the left side is the port on the left
side of the colon the right side is the
container you should really never mess
with the container side of things unless
you know what you're doing
if you don't really know what you're
doing as far as that application making
changes to the actual application
you should never mess with anything on
the right side of the colon but on the
left side this is the host and i know my
host is already using 3000 for another
application
so i'm going to change that to 30 30.
that's just something i have to do if
yours isn't using 3000 you can leave it
alone
just remember whatever port you put in
because we'll need that when we try to
access the site
next this is the file that we just
created while ago called
env if you changed the actual.docker.env
file
you should put that here if you didn't
create a emv file of your own
you need to put here whatever file has
your environment variables in it that
you want the system to use
so as we move down this is going to be a
postgres i didn't change this the db
name i
think i put cut maybe it was there
already i don't remember
dbuser i think i changed from their
default i know i did
because this is my name and then the db
password that you want they have a
default i suggest you change that to
something that's a little bit stronger
than what they have so make a make a
strong password
and then down here redis is what it is
that's fine just
leave that alone here with the reddest
stuff don't change anything just leave
it all alone
and then down here on the postgres side
you need to make this information match
what you have
up above so you have a user and a db
name and a password
and down here you have a user and a db
name here and a password those need to
match in both sections so make sure that
you make those match in both sections
and then as you keep coming down don't
change anything else just leave it all
the same and then once you're done we'll
get out of this file we'll save it
with control o hit enter and then you
can do control x to get out and you're
back at the terminal
so once you're back at the terminal you
can just type in docker hyphen compose
up now what this does is it lets you see
what happens as the as the application
builds
and once you hit control c or you close
the terminal it's going to kill your
application
so if you don't want that to happen you
need to do hyphen
d which means run it as a daemon so once
it's up and running
keep it running in the background so i'm
going to let this come up and run
it's going to show you what's going to
happen it's going to pull down all of
the stuff that it needs it's going to
pull down the images it's going to
extract them it's going to get
everything ready
and once it's got that stuff pulled down
and extracted it's going to try to make
that
cut system talk to the redis database
and the redis database to the postgres
database
so everything kind of works together you
know as three separate
images and containers just to make the
system work
properly so we're gonna go back here and
we're gonna go to our containers
and it says everything's running
so let's check and see if our site will
load this time
yeah so we're getting our security
warning i'm going to go ahead and click
advanced because it's a self-signed
certificate right now
let's say accept the risk and secure
connection failed
and i think yeah so it needs this to be
set as an
actual ip address so now we get to our
nginx proxy manager because it wants to
go to this site
not to the ip address so again that's
why i say you need an actual domain name
set up and ready to go and point it at
your at your
server regardless of how you're running
it so we're going to jump into nginx
proxy manager here
and i think i already have this entry
set so i'll have to go through
yeah so i'm just going to delete it and
start over so you guys can see uh
what we do edit there we go delete
yes so we'll just add it again here and
we'll go to add a host
and this is going to be osia.me
i'm going to hit tab to make sure it
gets a little chip
and then i'm going to put in my i'm
going to put in my docker 0 address
because it's running on the same
site on the same server as my docker
install
so i'm going to open up my terminal
again here and i'm going to do
ipaddr show and then docker 0
and that's going to show me my docker
address and i can just copy this right
here out of the terminal
and i can go back in here and i can just
paste that in
and then i know this is running on 3030
and i'm going to put websocket support i
don't know that it needs web sockets but
just in case
i'm just going to save that and then
let's click on it and see if it'll
actually go
it does so here here's here's my osi
a.m.e
so we've got this webpage here from
earlier with a really long
address there and we'll go out here and
we'll paste it in
and then i'll say here generate me a
short url and there you go there's my
short link
so if i copy that and again open another
tab
and paste
there we go so firefox for whatever
reason loves to try to take me to the
https
side of things and i don't really know
why but if you see that check and make
sure
if it put an https up there that may be
why it's why it's not working when you
first do this like i did
because i don't have https really set up
yet so
now i'm going to go back though so i'm
going to close these guys
and let me just close some of these down
because there's just too many things
open there
i'm going to go back to osia.me and i'm
going to say edit
and i'm going to say i want an ssl
certificate now i'm going to request a
new one
and i want to force ssl and i agree to
the terms and i have my email address
put in here
and i'm going to hit save
so it's going to go out it's going to
say hey i'd like to get an ssl
certificate for this can i reach it by
port 80 and if it goes away without any
error message it probably worked so let
me see if i can get to it with https now
i can and then let's just create another
one of those links for that same
site copy it and we'll paste it in there
and then let's click go
and then let's try this again
copy it and then let's open up another
tab here
and let's just see see it gives https
right away
so for me this makes sense to go ahead
and put the ssl certificate on it
and there we go so i've got a nice https
redirect that gives me everything i want
and i've got my link shortener
now what i want to show you is whenever
i try to do sign up slash login
right now if you try to do sign up it's
going to tell you hey you haven't
entered anything if you try to do log in
same thing
so brian at fix it delrio.com now if you
remember i set this email address
to be an actual admin so i'm just going
to put in a password here for
a long password and i'm going to say
sign up
it's going to show this i'm going to
tell it for now don't save but you
notice
it says an error occurred this is where
we run into the problem with my
email stuff not working so i've got my
email entered i've got everything set up
again
but again mail in a box uses port 587
for start tls
this doesn't really know how to navigate
start tls right now
i hope that at some point they'll fix
that because they'd be great because
it's a much more secure way to have your
smtp server running and sending email
but for now they support port 465 ssl
but my mail in a box does not
support that
took a little bit of work but i got it
done so that i could show you guys what
happens whenever you do this so
i did the sign in process that you saw a
while ago just click sign up and it
basically gives you this message when
it's successful
so it says it sent me a message so i'll
go to my email and check it here
and there it is verify your account
and you can see it has my little logo
here and it says click this to verify
the account so i'll click on it
should bring me back around and it says
your account has been successfully
verified
and we can just go here to log out or we
can go to settings
and there's probably not a ton of stuff
here that we can do but we'll look at it
so i want to make this just a little bit
bigger on the screen for you guys and
i'll scroll up a little bit
so custom domain um you can kind of see
what's going on here as far as what's
happening so it's point your domain a
record
to this um then add the domain
via the form below so i i don't know how
this works or what
this site is if we highlight that thing
and copy it
let's uh let's go do that we'll do a
little ns lookup here and see so i'm
i'm running this currently just in
docker compose up without the dash d so
i could see some some log output to see
what's going on from the site so i'll
just open up another terminal here
and i'll move it up and make the font
bigger here and we'll do an ns look up
of
that
so it can't find that
domain
interesting okay so i'm not sure exactly
what it's trying to to do there but um
anyways i guess if you want some custom
domains you can set up some other custom
domains you just need to point them at
this
particular site this might be something
from the cut.it people
there's an api so if you want to
generate an api key you can do that as
one of the administrators
you can of course change your password
if you want to you can change your email
address as well if you want to
and then you can delete your account so
just just a few settings
and these may be settings that any user
can get to this may not be specifically
admin settings
if you enjoyed this video like subscribe
tell your friends about it so they can
come along on the journey with us
and i'll talk to you next time

We are social