cmc/cleberg.net

My personal web garden & blog.

clone: git clone https://gitbay.org/cmc/cleberg.net.git

main: content/blog/2024-12-27-self-hosting-the-lounge.org · raw

  1#+date:        [2024-12-29 Sun 17:45:00]
  2#+title:       Self-Hosting Guide: The Lounge (IRC)
  3#+description: How to self-host The Lounge IRC client with Docker Compose.
  4#+slug:        self-hosting-the-lounge
  5#+filetags:    :linux:self-hosting:
  6
  7* The Lounge
  8
  9[[https://thelounge.chat/][The Lounge]] is a self-hosted IRC client for the web, which supports a lot of
 10desirable features for a modern IRC client. The Lounge supports push
 11notifications, link previews, file uploads, always connected, multi-user
 12support, and is available as a PWA for mobile devices.
 13
 14I wanted to write this as I had written a post about [[https://cleberg.net/blog/self-hosting-convos.html][self-hosting Convos]] and
 15have recently migrated over to The Lounge instead.
 16
 17If you'd like to try a demo first, head over to [[https://demo.thelounge.chat/][the official demo website]].
 18
 19** Installation (Docker)
 20
 21I install everything I can via Docker, so this tutorial will install The Lounge
 22with the Docker Compose platform.
 23
 24You can find the official docker version of The Lounge's repository on GitHub at
 25[[https://github.com/thelounge/thelounge-docker][thelounge-docker]].
 26
 27To start, let's create a directory for this app and create the =compose.yml= file.
 28
 29#+begin_src shell
 30mkdir thelounge
 31cd thelounge
 32nano compose.yml
 33#+end_src
 34
 35Within this configuration file, you can paste the content below and customize as
 36needed. If you want to use a different port on your machine, change the first
 37port on the =9000:9000= line. Additionally, you may move the volume to a
 38different location if required.
 39
 40#+begin_src yaml
 41services:
 42  thelounge:
 43    image: ghcr.io/thelounge/thelounge:latest
 44    container_name: thelounge
 45    ports:
 46      - "9000:9000"
 47    restart: always
 48    volumes:
 49      - ./.thelounge:/var/opt/thelounge
 50#+end_src
 51
 52Save and close the file and you can now launch the service.
 53
 54#+begin_src shell
 55sudo docker compose up -d
 56#+end_src
 57
 58The service is now available at =localhost:9000= or =machine_ip:9000= if you're
 59browsing from a different device. Don't forget to allow the port through your
 60machine's firewall, if you have one enabled.
 61
 62#+caption: Login
 63#+attr_html: :alt The Lounge login page with username and password fields.
 64[[https://img.cleberg.net/blog/20241229-thelounge/login.webp]]
 65
 66** Nginx Reverse Proxy
 67
 68If you want to access the service via a domain name (=thelounge.example.com=),
 69you can use Nginx as a reverse proxy.
 70
 71First, create the Nginx configuration file.
 72
 73#+begin_src shell
 74sudo nano /etc/nginx/conf.d/
 75#+end_src
 76
 77The configuration below assumes you have a wildcard certificate for HTTPS (:443)
 78traffic via =example.com=. If you don't, you'll need to obtain an SSL
 79certificate to use HTTPS.
 80
 81#+begin_src configuration
 82upstream irc_upstream { server 127.0.0.1:9000; }
 83
 84# HTTP redirect
 85server {
 86	listen      80;
 87	listen      [::]:80;
 88	server_name thelounge.example.com;
 89	include     custom.d/letsencrypt.conf;
 90
 91	if ($host ~ ^[^.]+\.example\.com) {
 92		return 301 https://$host$request_uri;
 93	}
 94}
 95
 96# HTTPS
 97server {
 98	listen                  443 ssl;
 99	listen                  [::]:443 ssl;
100	http2			on;
101	server_name             thelounge.example.com;
102
103	# SSL
104	ssl_certificate         /etc/letsencrypt/live/example.com/fullchain.pem;
105	ssl_certificate_key     /etc/letsencrypt/live/example.com/privkey.pem;
106	ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem;
107
108	# reverse proxy
109	location / {
110	        proxy_pass           http://irc_upstream;
111	        client_max_body_size 0;
112	        proxy_set_header     X-Request-Base "$scheme://$host/";
113
114		# Standard reverse proxy settings
115		proxy_set_header Host $host;
116		proxy_set_header Upgrade $http_upgrade;
117		proxy_set_header Connection upgrade;
118		proxy_set_header Accept-Encoding gzip;
119		proxy_set_header X-Real-IP $remote_addr;
120		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
121		proxy_set_header X-Forwarded-Proto $scheme;
122		proxy_set_header X-Forwarded-Host $http_host;
123		proxy_set_header X-Forwarded-Uri $request_uri;
124		proxy_set_header X-Forwarded-Ssl on;
125		proxy_redirect  http://  $scheme://;
126		proxy_http_version 1.1;
127		proxy_set_header Connection "";
128		proxy_cache_bypass $cookie_session;
129		proxy_no_cache $cookie_session;
130		proxy_buffers 64 256k;
131	}
132}
133#+end_src
134
135Finally, restart Nginx to see the effects.
136
137#+begin_src shell
138sudo systemctl restart nginx.service
139#+end_src
140
141** Initial Setup
142
143The first thing you'll need to do is create a user. You can do this with the
144docker container with the following command, which will ask for a password.
145
146#+begin_src shell
147sudo docker exec --user node -it thelounge thelounge add [username]
148#+end_src
149
150Once the user has been created, you'll be able to log in to the web interface.
151Once created, you can change your password in the settings panel of the web
152interface.
153
154Finally, you can connect to an IRC server with the plus (=+=) button at the
155bottom of the sidebar and connect to individual channels or users via the plus
156(=+=) button next to your server's name in the sidebar.
157
158#+caption: New Server Connection
159#+attr_html: :alt Settings for network, proxy, preferences, and authentication.
160[[https://img.cleberg.net/blog/20241229-thelounge/new_connection.webp]]
161
162#+caption: Existing Server Connection
163#+attr_html: :alt Libera.Chat server connection log and status.
164[[https://img.cleberg.net/blog/20241229-thelounge/existing_connection.webp]]
165
166#+caption: Channel View
167#+attr_html: :alt View of the #emacs channel on Libera.Chat.
168[[https://img.cleberg.net/blog/20241229-thelounge/channel.webp]]