Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sachinsenals/4536547d0771ef9681d1548e098edfe6 to your computer and use it in GitHub Desktop.
Save sachinsenals/4536547d0771ef9681d1548e098edfe6 to your computer and use it in GitHub Desktop.
qBittorrent with Web UI on Ubuntu 20.04 (lazy guide)

qBittorrent with Web UI on Ubuntu 20.04 (lazy guide)

WARNING: this guide is not about security, but about functionality, for example, never run applications as root. Be cautious.

sudo su
add-apt-repository ppa:qbittorrent-team/qbittorrent-stable && \
apt install -y qbittorrent qbittorrent-nox
cat > /etc/systemd/system/qbittorrent-nox.service << EOF
[Unit]
Description=qBittorrent Command Line Client
After=network.target

[Service]
Type=forking
User=root
Group=root
UMask=000
ExecStart=/usr/bin/qbittorrent-nox -d --webui-port=8212
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload && \
systemctl enable qbittorrent-nox && \
systemctl stop qbittorrent-nox && \
systemctl start qbittorrent-nox && \
systemctl status qbittorrent-nox

Using

Create Apache Reverse Proxy - HTTP

sudo su

apt update && \
apt install -y apache2 && \
a2enmod proxy proxy_http headers proxy_wstunnel

DOMAIN=qbit.yourdomain.tld && \
rm -f /etc/apache2/sites-available/$DOMAIN.conf && \
cat > /etc/apache2/sites-available/$DOMAIN.conf << EOF
<VirtualHost *:80>
   ServerName $DOMAIN
   ErrorDocument 404 /404.html

   #HTTP proxy
   ProxyPass / http://localhost:8212/
   ProxyPassReverse / http://localhost:8212/

   #Websocket proxy
   SSLProxyEngine on
   <Location /:/websockets/notifications>
        ProxyPass wss://localhost:8212/:/websockets/notifications
        ProxyPassReverse wss://localhost:8212/:/websockets/notifications
   </Location>

   Header always unset X-Frame-Options
</VirtualHost>
EOF

DOMAIN=qbit.yourdomain.tld && \
a2ensite $DOMAIN.conf && \
systemctl restart apache2

Optional - Enable HTTPS

sudo su

apt install -y certbot python3-certbot-apache

DOMAIN=qbit.yourdomain.tld && \
EMAIL=qbit@yourdomain.tld && \
certbot --apache --agree-tos --redirect --hsts --staple-ocsp --email $EMAIL -d $DOMAIN

systemctl restart apache2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment