Setting up Kutt on MyPad.in running Ubuntu

Setting up Kutt on MyPad.in running Ubuntu
It is sometime cool to have a tiny url customized the way you want without burning a hole in your pocket! Kutt helps with that!
And yeah ... this post is going to be available at https://l.mypad.in/install-kutt :-)
Install Postgres
Follow instructions mentioned here
# Step 1 — Installing PostgreSQL
sudo apt update
sudo apt install postgresql postgresql-contrib
# Switch over to the postgres account on your server by typing:
sudo -i -u postgres
# You can now access a Postgres prompt immediately by typing:
psql
# Exit out of the PostgreSQL prompt by typing:
\q
# Step 3 — Creating a New Role
sudo -u postgres createuser --interactive
# i created a user called psql_ghost
# Step 4 — Creating a New Database
sudo -u postgres createdb kutt
# Step 5 — Opening a Postgres Prompt with the New Role
# To log in with ident based authentication, you’ll need a Linux user with the same name as your Postgres role and database.
sudo adduser psql_ghost
# Once this new account is available, you can either switch over and connect to the database
sudo -i -u psql_ghost
psql -d kutt
\password psql_ghost
Install Redis
Follow instructions mentioned here
# Step 1 — Installing and Configuring Redis
sudo apt update
sudo apt install redis-server
sudo nano /etc/redis/redis.conf
Configure kutt
Modify .env
file per your requirements
Setup NGINX
My nginx site config looks like this and works fine.
server {
if ($host = l.mypad.in) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name l.mypad.in;
listen 80;
return 404; # managed by Certbot
}
server {
server_name l.mypad.in; # Replace with your domain
access_log /var/log/l_mypad_acc.log;
error_log /var/log/l_mypad_err.log;
location / {
proxy_pass http://localhost:3014;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/l.mypad.in/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/l.mypad.in/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
Setup Lets Encrypt
Use Lets Encrypt to secure you site for free! Just follow the instructions mentioned here. Works like magic!
Build Kutt
npm run build
Create kutt service
Setup kutt
as a service:
sudo nano /etc/systemd/system/kutt_mypad.service
[Unit]
Description=Kutt on MyPad
After=network.target
[Service]
Type=simple
WorkingDirectory=/home/ghost/Dropbox/pandora/My-Projects/repos/kutt
User=ghost
Group=ghost
ExecStart=/usr/local/bin/npm start
ExecStop=/usr/local/bin/npm stop
Restart=always
SyslogIdentifier=KuttMyPad
[Install]
WantedBy=multi-user.target
sudo systemctl enable kutt_mypad.service
sudo systemctl start kutt_mypad.service
sudo systemctl status kutt_mypad.service
sudo systemctl stop kutt_mypad.service
Create Api Key
Log into kutt
and create your api-key
Install the Chrome Extension
Install the chrome extension available at https://l.mypad.in and shorten any link easily after setting up the api-key. You don't get custom links using the extension. But, you could hack the code a little or be happy that you have shiny and tiny link anyway. Need help? Let's discuss.
Questions / Comment / Feedback
Drop me a note! ;-)