Introduction:

If you are like me and you come across a bunch of great information, but don’t have time to read each individual article services like Pocket, Instapaper, and Wallabag can be helpful. I have tried all of these services and I want a service that has a good UI and allows me to keep my data. Wallabag stood out to me because it has the best UI, I can keep my data and it is open source. Services like these help people organize their lives and can provide the basis for a personal google. There are many ways to set up a Wallabag the easiest is through docker compose. I prefer to have a separate Postgres instance on a different server and not dockerize my Nginx. So, instead of docker compose I set up a Wallabag server and hooked in Postgres and Nginx.

https://wallabag.org/en

Step 1: Set up digital ocean server

If you are using a different VPS please set up a server with Ubuntu 16.04 and skip this step.

Digital Ocean is one of the many different server platforms you can use to set up your personal projects. They are one of the cheapest VPS providers with instances as low as $5 a month. If you are new to Digital Ocean you can get a $10 credit with this link. Once you have signed up you can launch a droplet (server) using this guide. All we will need for this tutorial is a $5 instance. When creating a droplet please use Ubuntu 16.04 and make sure you create an ssh key, enable private networking, enable monitoring and enable ipv6. Of those only having Ubuntu 16.04 is required for the rest of the tutorial everything else is optional, but strongly recommend.

Once your droplet is created please go through steps 1-3 in this guide in order to set up a non-root user. Once you have that all set up you are ready to install Docker.

Step 2: Set up docker

Docker allows a developer to package their program in a way that makes development and deployment on different machines easier. It will be the way we deploy Wallabag. If you do not have a docker snapshot you can run this script on your local terminal. To run it you will need to clone the repo or copy the file to your local machine and run the commands below. If you do not have Pipenv please install it using one of the techniques here.

pipenv shell
python setup_docker.py -s root@SERVER_IP

The command worked if you see the output below.

Output indicating docker is running

Once we have docker set up we can install Postgres which is a relational database and will allow us to persist our Wallabag users and articles.

Step 3: Set up Postgres

If you do not have a snapshot with Postgres on it you can either follow this guide or run this script with the command below.

python setup_postgres.py -s root@SERVER_IP

When running the script you will be prompted for the name and and role. Please input the following.

Enter name of role to add: sammy
Shall the new role be a superuser? (y/n) y

Once we have Postgres we have all the components to run our Wallabag server.

Step 3.5: Set up SMTP server (Optional)

If you plan on opening up your server for others to use you should probably set up an SMTP server using Mailgun.

Step 4: Run docker image

To run the Wallabag docker image we first need to ssh into our server and pull down the image from docker hub:

ssh root@ip-address
su sammy
sudo docker pull wallabag/wallabag

Once the image is pulled you will need to create a file to hold your environment variables.

touch .wallabag.env

Add the following values to the file:

POSTGRES_PASSWORD=?
POSTGRES_USER=?
SYMFONY__ENV__DATABASE_DRIVER=pdo_pgsql
SYMFONY__ENV__DATABASE_DRIVER_CLASS=Wallabag\CoreBundle\Doctrine\DBAL\Driver\CustomPostgreSQLDriver
SYMFONY__ENV__DATABASE_HOST=?
SYMFONY__ENV__DATABASE_PORT=5432
SYMFONY__ENV__DATABASE_NAME=wallabag
SYMFONY__ENV__DATABASE_USER=wallabag
SYMFONY__ENV__DATABASE_PASSWORD=wallapass
SYMFONY__ENV__DOMAIN_NAME=?
SYMFONY__ENV__SECRET=?
SYMFONY__ENV__FOSUSER_REGISTRATION=true
SYMFONY__ENV__FOSUSER_CONFIRMATION=true

You will need to replace the question marks with values relevant to your Postgres server or container values. Please use a long randomly generated string for the secret. Now to run the server use the command below.

sudo docker run --name wallabag \
                --env-file .wallabag.env \
                -d -p 8080:80 wallabag/wallabag

You can look at the logs for your program by getting the container id by running

docker ps

and then printing the logs with

docker logs CONTIANER_ID -f

Once the image is running wait a couple of minutes and then you should be able to hit the IP of your server on port 8080 and see a login page like below. An example would look like http://206.189.193.74:8080/ in the browser.

If some images and styles are missing it is probably because you are not using your IP or domain in the DOMAIN_NAME environment variable. The DOMAIN_NAME variable should be the same as the URL you input above http://IP-address:8080. If everything looks good we can set up Nginx to route traffic to our container.

Step 5: Set up ngnix:

Again Digital Ocean has a great article on setting up Nginx. If going through that tutorial is too much I made a script which runs the commands in the article. Run it using the command below.

python setup_nginx.py -s root@ip-address

After running the script the final output should look like below.

There are a couple of problems with our current setup. Right now, we don't have a human-readable name to hit the service and our service is using HTTP instead of HTTPS which means our connections are not secure. In the next couple steps, we will set up a domain and make our app default to HTTPS instead of HTTP.

Step 6: Buying a domain

First, we need to buy a domain. There are a ton of places to buy a domain. For my app, I decided to go with Google. I wanted to manage my domain through digital ocean which requires me to point my domain DNS servers to the digital ocean. To point the Gmail servers to the digital ocean DNS servers go to your google domain and your name servers should look something like below.

Domain pointing at Digital Ocean name servers

Once that is done you need to set up A certificates for an ip4 server address and AAAA certificates for ip6 connections. Now, wait 24-48 hours for your domain to propagate to the correct DNS servers. After waiting you should be ready to setup your domain in Nginx and add SSL

Step 7: Setup domain on Nginx

Run the following commands

cd etc/nginx/sites-available
touch mydomain.com
vim mydomain.com
server {
       listen      80;
       listen [::]:80;
       server_name    mydomain.com www.mydomain.com;
       location / {
                proxy_pass http://localhost:8080/;
                proxy_set_header X-Forwarded-Host $server_name;
                proxy_set_header X-Forwarded-Proto http;
                proxy_set_header X-Forwarded-For $remote_addr;
        }
}

Then restart nginx. If that looks good copy the file into

cp mydomain.com /etc/nginx/sites-enabled

Then restart nginx

systemctl restart nginx

If there are no errors you should be able to get the login screen by add mydomain.com to the browser. We still need to have SSL to get a secure connection

Step 8: Add SSL

We are going to use Let’s Encrypt for SSL. We are going to remove everything in the mydomain.com file and replace it with the below

server {
        listen [::]:443 ssl ipv6only=on;
        listen 443 ssl;
        server_name mydomain.com www.mydomain.com;

        location / {
                proxy_pass http://localhost:8080/;
                proxy_set_header X-Forwarded-Host $server_name;
                proxy_set_header X-Forwarded-Proto http;
                proxy_set_header X-Forwarded-For $remote_addr;
        }


}

server {
    if ($host = www.mydomain.com) {
        return 301 https://$host$request_uri;
    }

    if ($host = mydomain.com) {
        return 301 https://$host$request_uri;
    }

        listen 80;
        server_name mydomain.com www.mydomain.com;
    return 404;

}

In order to setup SSL run the commands below while you are ssh'd into the server.

sudo add-apt-repository ppa:certbot/certbot

sudo apt-get update

sudo apt-get install python-certbot-nginx

sudo certbot --nginx -d mydomain.com -d www.mydomain.com

sudo certbot renew

sudo apt-get remove python-certbot-nginx

Now we should see a little lock in the top left corner when we go to mydomain.com in the browser. This means we are using https. Hope this was helpful! You can checkout my instance at wallabag.alexkeating.me.

Enjoy Wallabag!

If you are loving your Wallabag instance please consider donating to the good people that develop and maintain Wallabag here.