aboutsummaryrefslogtreecommitdiff
path: root/content/blog/2023-06-30-self-hosting-voyager.org
blob: 23646d20effccc38a88ec58b1ce48996e596194c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#+date:        <2023-06-30 Fri 00:00:00>
#+title:       Self-Hosting Guide: Voyager for Lemmy
#+description: Instructions for building, running, and reverse proxying Voyager, a Lemmy web client, on a server environment utilizing Docker and Nginx components.
#+slug:        self-hosting-voyager
#+filetags:    :docker:lemmy:voyager:

* Installation Guide

[[https://github.com/aeharding/voyager][Voyager]] is a mobile-first
Lemmy web client, based on iOS design standards. It follows very closely
to Apollo's design.

This post is a guide showing how I was able to build and launch my own
instance of Voyager via Docker Compose.

** Clone the Repository

Start by cloning the repository and entering it:

#+begin_src sh
git clone https://github.com/aeharding/voyager
cd voyager
#+end_src

** Build the Image

With this repository, you can build the image yourself without any
further configuration. When complete, it'll give you the image ID for
you to run.

#+begin_src sh
sudo docker build .
# Successfully built 5f00723cb5be
#+end_src

With the image ID above, you can run the container and pass the
requested port =5314= through or use a custom port, if you wish.

You can also set the =CUSTOM_LEMMY_SERVERS= environment variable if you
want to add to the default suggested login servers. This must be set
with a comma separated list of suggested servers. The first instance in
the list will be the default view for logged-out users.

I will be using a =docker-compose.yml= file to run this container,
instead of a =docker run= command.

#+begin_src sh
nano docker-compose.yml
#+end_src

#+begin_src conf
version: "2"
services:
  voyager:
    image: 5f00723cb5be
    restart: always
    ports:
      - "<custom_port>:5314"
    environment:
      - CUSTOM_LEMMY_SERVERS=lemmy.dbzer0.com,lemmy.world,lemmy.ml,beehaw.org
#+end_src

#+begin_src sh
sudo docker-compose up -d
#+end_src

The web app will now be available at the following address:
=<machine_ip>:<custom_port>=. If you are running it on your local
device, try =localhost:<custom_port>=.

** Reverse Proxy

If you want to visit this app via an external URL or domain name, you'll
need to set up a reverse proxy. The example below uses Nginx as a
reverse proxy.

Simply create the configuration file, paste the contents below, save the
file, symlink the file, and restart Nginx.

#+begin_src sh
sudo nano /etc/nginx/sites-available/voyager
#+end_src

#+begin_src conf
server {
    if ($host ~ ^[^.]+\.example\.com$) {
        return 301 https://$host$request_uri;
    }

    listen [::]:80;
    listen 80;
    server_name voyager.example.com;
    return 404;
}

server {
    listen [::]:443 ssl http2;
    listen 443 ssl http2;
    server_name voyager.example.com;
    access_log  /var/log/nginx/voyager.access.log;
    error_log   /var/log/nginx/voyager.error.log;

    location / {
        proxy_http_version 1.1;
        proxy_pass http://localhost:5314;
        proxy_set_header Host $host;
    }

    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}
#+end_src

#+begin_src sh
sudo ln sudo ln -s /etc/nginx/sites-available/voyager /etc/nginx/sites-enabled/voyager
sudo systemctl restart nginx.service
#+end_src

The site will now be available at the =server_name= you specified above!

You can visit my instance at
[[https://voyager.cleberg.net][voyager.cleberg.net]] for an example.