Commit 079af851d8
Unsigned
Layout: unified · split
content/blog/2024-09-23-self-hosting-transmission.org added +182
| @@ -0,0 +1,182 @@ | ||
| 1 | #+date: <2024-09-23 Mon 19:52:20> | |
| 2 | #+title: Self-Hosting Transmission Bittorrent Client | |
| 3 | #+description: Learn how to self-host the Transmission torrent client with an Nginx reverse proxy. | |
| 4 | #+filetags: :self-hosting: | |
| 5 | #+slug: self-hosting-transmission | |
| 6 | ||
| 7 | #+begin_quote | |
| 8 | If you're torrenting anything sensitive, I *highly* recommend you use a VPN. | |
| 9 | Something like mullvad-cli is incredibly simple to use and can be configured to | |
| 10 | have a "killswitch" or "lockdown mode" to ensure that if the VPN disconnects, | |
| 11 | your traffic won't be leaked to your ISP. | |
| 12 | #+end_quote | |
| 13 | ||
| 14 | * Transmission | |
| 15 | ||
| 16 | [[https://transmissionbt.com/][Transmission]] is a cross-platform bittorrent client that supports running a | |
| 17 | [[https://linux.die.net/man/1/transmission-remote][remote control utility]], a [[https://linux.die.net/man/1/transmission-daemon][daemon service]] for running as a background service, | |
| 18 | and a [[https://linux.die.net/man/1/transmission-cli][command-line client]]. | |
| 19 | ||
| 20 | Since I love torrenting Linux ISOs and providing them back to the community, | |
| 21 | let's walk through a tutorial of setting up Transmission on a headless server | |
| 22 | and connecting it to a domain name (=transmission.example.com=) so that we can | |
| 23 | manage our torrents remotely. | |
| 24 | ||
| 25 | This tutorial assumes you have a Linux machine, have Nginx installed, and have a | |
| 26 | domain name pointing at your Linux machine. | |
| 27 | ||
| 28 | ** Installation | |
| 29 | ||
| 30 | First, let's install a couple Transmission packages on the system. We don't need | |
| 31 | the GUI components, so we'll only install the daemon and command line interface | |
| 32 | utilities. | |
| 33 | ||
| 34 | #+begin_src sh | |
| 35 | sudo apt install transmission-cli transmission-common transmission-daemon | |
| 36 | #+end_src | |
| 37 | ||
| 38 | You will need to run the program to initialize the files before you can edit the | |
| 39 | configurations, so let's run it and end the process. | |
| 40 | ||
| 41 | #+begin_src sh | |
| 42 | # Run the program | |
| 43 | transmission-daemon -e ~/.local/log/transmission.log | |
| 44 | ||
| 45 | # End the program after it finishes running | |
| 46 | transmission-remote --exit | |
| 47 | #+end_src | |
| 48 | ||
| 49 | ** Configuration | |
| 50 | ||
| 51 | Now that we've run the program for the first time and initialized the relevant | |
| 52 | files, let's edit those files. | |
| 53 | ||
| 54 | #+begin_quote | |
| 55 | If you edit the files while Transmission is running, your changes won't be | |
| 56 | saved! Make sure to end the service, update the configuration files, and restart | |
| 57 | the service. | |
| 58 | #+end_quote | |
| 59 | ||
| 60 | To start, let's edit the main configuration file. | |
| 61 | ||
| 62 | #+begin_src sh | |
| 63 | nano ~/.config/transmission-daemon/settings.json | |
| 64 | #+end_src | |
| 65 | ||
| 66 | Within this file, I suggesting skimming *every* option and determining if you | |
| 67 | want to change any of those options. | |
| 68 | ||
| 69 | For remote access, we will focus on the following =rpc= options. This | |
| 70 | configuration will not require authentication, will allow any device with access | |
| 71 | (I suggest that you have a firewall restricting access) to access the service | |
| 72 | (="rpc-bind-access": "0.0.0.0"=), will open the service on port =9091=, and will | |
| 73 | whitelist a few LAN IPs (="rpc-whitelist": | |
| 74 | "127.0.0.1,::1,192.168.0.98,192.168.0.97"=). | |
| 75 | ||
| 76 | #+begin_src json | |
| 77 | { | |
| 78 | ... | |
| 79 | "rpc-authentication-required": false, | |
| 80 | "rpc-bind-address": "0.0.0.0", | |
| 81 | "rpc-enabled": true, | |
| 82 | "rpc-host-whitelist": "", | |
| 83 | "rpc-host-whitelist-enabled": true, | |
| 84 | "rpc-password": "{7fc02520b97e054f7a15274c7cfafe3cd7330169.OQUAUS4", | |
| 85 | "rpc-port": 9091, | |
| 86 | "rpc-socket-mode": "0750", | |
| 87 | "rpc-url": "/transmission/", | |
| 88 | "rpc-username": "", | |
| 89 | "rpc-whitelist": "127.0.0.1,::1,192.168.0.98,192.168.0.97", | |
| 90 | "rpc-whitelist-enabled": true, | |
| 91 | ... | |
| 92 | } | |
| 93 | #+end_src | |
| 94 | ||
| 95 | Once you've finished configuring the service, start the service up again. | |
| 96 | ||
| 97 | #+begin_src sh | |
| 98 | transmission-daemon -e ~/.local/log/transmission.log | |
| 99 | #+end_src | |
| 100 | ||
| 101 | At this point, you should be able to access the website at =localhost:9091= (if | |
| 102 | you're browsing on the machine where Transmission is running) or | |
| 103 | =$server_ip:9091= (if you're browsing from a different LAN device). | |
| 104 | ||
| 105 | If you want to make further changes to Transmission's configuration, I suggest | |
| 106 | doing so now. Once you start working on remote access via a reverse proxy, | |
| 107 | you'll be adding an additional layer of complexity that bring in more confusion | |
| 108 | when errors occur. | |
| 109 | ||
| 110 | * Reverse Proxy | |
| 111 | ||
| 112 | Now that the service is running and configured properly, let's work on remote | |
| 113 | access. | |
| 114 | ||
| 115 | This tutorial will use Nginx, but you can use any reverse proxy or something | |
| 116 | like Cloudflare Tunnels if that's your thing. | |
| 117 | ||
| 118 | ** Configuration | |
| 119 | ||
| 120 | If you have Nginx installed, you should have either the =/etc/nginx/conf.d= or | |
| 121 | =/etc/nginx/sites-available= directories available to create website | |
| 122 | configuration files. This tutorial assumes the =conf.d= structure, but it's | |
| 123 | essentially the same except using the =sites-available= structure requires you | |
| 124 | to symlink your files into the =sites-enabled= directory. | |
| 125 | ||
| 126 | Let's start by creating the website configuration file. | |
| 127 | ||
| 128 | #+begin_src sh | |
| 129 | sudo nano /etc/nginx/conf.d/transmission.conf | |
| 130 | #+end_src | |
| 131 | ||
| 132 | Within the file, you will need a configuration similar to the code below. Note | |
| 133 | that this uses SSL and requires a valid TLS/SSL certificate. You can use [[https://letsencrypt.org/][Let's | |
| 134 | Encrypt]] if you don't have a certificate yet. | |
| 135 | ||
| 136 | #+begin_src conf | |
| 137 | server { | |
| 138 | listen 443 ssl; | |
| 139 | listen [::]:443 ssl; | |
| 140 | http2 on; | |
| 141 | server_name transmission.example.com; | |
| 142 | ||
| 143 | # SSL | |
| 144 | ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; | |
| 145 | ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; | |
| 146 | ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem; | |
| 147 | ||
| 148 | # reverse proxy | |
| 149 | location / { | |
| 150 | set $upstream_transmission http://localhost:9091; | |
| 151 | proxy_pass $upstream_transmission; | |
| 152 | proxy_pass_header X-Transmission-Session-Id; | |
| 153 | } | |
| 154 | } | |
| 155 | ||
| 156 | # HTTP redirect | |
| 157 | server { | |
| 158 | listen 80; | |
| 159 | listen [::]:80; | |
| 160 | server_name transmission.example.com; | |
| 161 | ||
| 162 | if ($host ~ ^[^.]+\.example\.com) { | |
| 163 | return 301 https://$host$request_uri; | |
| 164 | } | |
| 165 | } | |
| 166 | #+end_src | |
| 167 | ||
| 168 | Once you've saved the configuration file, restart the Nginx web server to enable | |
| 169 | the remote access connection. | |
| 170 | ||
| 171 | #+begin_src sh | |
| 172 | sudo systemctl restart nginx.service | |
| 173 | #+end_src | |
| 174 | ||
| 175 | At this point, Transmission should now be available at | |
| 176 | =transmission.example.com=, same as it's available on the LAN. | |
| 177 | ||
| 178 | #+begin_quote | |
| 179 | Pro Tip: If you dislike something about the website UI, you can edit the | |
| 180 | website's files in the =/usr/share/transmission/public_html/= directory. You can | |
| 181 | modify the HTML, CSS, and JS files in this directory. | |
| 182 | #+end_quote | |
theme/templates/index.html +4 −6
| @@ -8,6 +8,10 @@ uid [ultimate] Christian Cleberg <hello@cleberg.net></pre> | ||
| 8 | 8 | <section> |
| 9 | 9 | <h2>Recent Blog Posts</h2> |
| 10 | 10 | |
| 11 | <div class="post> | |
| 12 | <time datetime="2024-09-23 19:52:20">2024-09-23</time> | |
| 13 | <a href="/blog/self-hosting-transmission.html">Self-Hosting Transmission Bittorrent Client</a> | |
| 14 | </div> | |
| 11 | 15 | <div class="post"> |
| 12 | 16 | <time datetime="2024-09-20 13:38:52">2024-09-20</time> |
| 13 | 17 | <a href="/blog/prometheus-grafana-cloud.html" |
| @@ -20,12 +24,6 @@ uid [ultimate] Christian Cleberg <hello@cleberg.net></pre> | ||
| 20 | 24 | >Email Sentiment Analysis With n8n</a |
| 21 | 25 | > |
| 22 | 26 | </div> |
| 23 | <div class="post"> | |
| 24 | <time datetime="2024-08-11 20:18:15">2024-08-11</time> | |
| 25 | <a href="/blog/org-mode-features.html" | |
| 26 | >My Top 8 Most Used Org-Mode Features</a | |
| 27 | > | |
| 28 | </div> | |
| 29 | 27 | |
| 30 | 28 | <br /> |
| 31 | 29 | <a href="/blog/">All Posts →</a> |