content/blog/2024-12-27-self-hosting-the-lounge.org

0b2895a90c7751ce06e4b26d4db41005ea2f40a9
cleberg.net/content/blog/2024-12-27-self-hosting-the-lounge.org rendered · source · history · blame · raw

164 lines · 5395 bytes

  1#+date:        <2024-12-29 Sun 17:45:00>
  2#+title:       Deployment Procedure for The Lounge IRC Web Client Using Docker Compose on Linux
  3#+description: Step-by-step instructions for installing and configuring The Lounge IRC web client on Linux systems utilizing Docker Compose to provide persistent and secure chat access.
  4#+slug:        self-hosting-the-lounge
  5#+filetags:    :docker:irc:web-client:
  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[[https://img.cleberg.net/blog/20241229-thelounge/login.png]]
 64
 65** Nginx Reverse Proxy
 66
 67If you want to access the service via a domain name (=thelounge.example.com=),
 68you can use Nginx as a reverse proxy.
 69
 70First, create the Nginx configuration file.
 71
 72#+begin_src shell
 73sudo nano /etc/nginx/conf.d/
 74#+end_src
 75
 76The configuration below assumes you have a wildcard certificate for HTTPS (:443)
 77traffic via =example.com=. If you don't, you'll need to obtain an SSL
 78certificate to use HTTPS.
 79
 80#+begin_src configuration
 81upstream irc_upstream { server 127.0.0.1:9000; }
 82
 83# HTTP redirect
 84server {
 85	listen      80;
 86	listen      [::]:80;
 87	server_name thelounge.example.com;
 88	include     custom.d/letsencrypt.conf;
 89
 90	if ($host ~ ^[^.]+\.example\.com) {
 91		return 301 https://$host$request_uri;
 92	}
 93}
 94
 95# HTTPS
 96server {
 97	listen                  443 ssl;
 98	listen                  [::]:443 ssl;
 99	http2			on;
100	server_name             thelounge.example.com;
101
102	# SSL
103	ssl_certificate         /etc/letsencrypt/live/example.com/fullchain.pem;
104	ssl_certificate_key     /etc/letsencrypt/live/example.com/privkey.pem;
105	ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem;
106
107	# reverse proxy
108	location / {
109	        proxy_pass           http://irc_upstream;
110	        client_max_body_size 0;
111	        proxy_set_header     X-Request-Base "$scheme://$host/";
112
113		# Standard reverse proxy settings
114		proxy_set_header Host $host;
115		proxy_set_header Upgrade $http_upgrade;
116		proxy_set_header Connection upgrade;
117		proxy_set_header Accept-Encoding gzip;
118		proxy_set_header X-Real-IP $remote_addr;
119		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
120		proxy_set_header X-Forwarded-Proto $scheme;
121		proxy_set_header X-Forwarded-Host $http_host;
122		proxy_set_header X-Forwarded-Uri $request_uri;
123		proxy_set_header X-Forwarded-Ssl on;
124		proxy_redirect  http://  $scheme://;
125		proxy_http_version 1.1;
126		proxy_set_header Connection "";
127		proxy_cache_bypass $cookie_session;
128		proxy_no_cache $cookie_session;
129		proxy_buffers 64 256k;
130	}
131}
132#+end_src
133
134Finally, restart Nginx to see the effects.
135
136#+begin_src shell
137sudo systemctl restart nginx.service
138#+end_src
139
140** Initial Setup
141
142The first thing you'll need to do is create a user. You can do this with the
143docker container with the following command, which will ask for a password.
144
145#+begin_src shell
146sudo docker exec --user node -it thelounge thelounge add [username]
147#+end_src
148
149Once the user has been created, you'll be able to log in to the web interface.
150Once created, you can change your password in the settings panel of the web
151interface.
152
153Finally, you can connect to an IRC server with the plus (=+=) button at the
154bottom of the sidebar and connect to individual channels or users via the plus
155(=+=) button next to your server's name in the sidebar.
156
157#+caption: New Server Connection
158[[https://img.cleberg.net/blog/20241229-thelounge/new_connection.png]]
159
160#+caption: Existing Server Connection
161[[https://img.cleberg.net/blog/20241229-thelounge/existing_connection.png]]
162
163#+caption: Channel View
164[[https://img.cleberg.net/blog/20241229-thelounge/channel.png]]