Skip to content
This repository was archived by the owner on Jun 11, 2025. It is now read-only.

Allow for qBittorrent WebGUI to run in HTTPS #17

Merged
merged 7 commits into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ RUN sed -i "/${LANG}/s/^# //g" /etc/locale.gen && \

ENV QBITTORRENT_SERVER=localhost
ENV QBITTORRENT_PORT=8080
ENV QBITTORRENT_SERVER_HTTP_OR_HTTPS=http
ENV QBITTORRENT_USER=admin
ENV QBITTORRENT_PASS=adminadmin
ENV VPN_GATEWAY=
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ These actions are performed continuously (in a loop, every 5 minutes (default, c
* QBITTORRENT_PORT (Defaults to **8080**)
* QBITTORRENT_USER (Defaults to **admin**)
* QBITTORRENT_PASS (Defaults to **adminadmin**)
* QBITTORRENT_SERVER_HTTP_OR_HTTPS (Defaults to **http**)
* Use either http or https depending on the qBittorrent WebUI setting.
* VPN_GATEWAY (Defaults to **empty**)
* If not set the script will try and find it
* The value for this variable will be the `VPN_IF_NAME` (default: tun0) gateway address, not the `VPN_ENDPOINT_IP` from the Gluetun/VPN Container when using Wireguard, [more info here](https://github.com/qdm12/gluetun/wiki/Custom-provider#wireguard-only).
Expand Down
9 changes: 5 additions & 4 deletions data/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ getpublicip() {
}

findconfiguredport() {
curl -s -i --header "Referer: http://${QBITTORRENT_SERVER}:${QBITTORRENT_PORT}" --cookie "$1" "http://${QBITTORRENT_SERVER}:${QBITTORRENT_PORT}/api/v2/app/preferences" | grep -oP '(?<=\"listen_port\"\:)(\d{1,5})'
curl -s -k -i --header "Referer: ${QBITTORRENT_SERVER_HTTP_OR_HTTPS}://${QBITTORRENT_SERVER}:${QBITTORRENT_PORT}" --cookie "$1" "${QBITTORRENT_SERVER_HTTP_OR_HTTPS}://${QBITTORRENT_SERVER}:${QBITTORRENT_PORT}/api/v2/app/preferences" | grep -oP '(?<=\"listen_port\"\:)(\d{1,5})'
}

findactiveport() {
Expand All @@ -56,17 +56,17 @@ findactiveport() {
}

qbt_login() {
qbt_sid=$(curl -s -i --header "Referer: http://${QBITTORRENT_SERVER}:${QBITTORRENT_PORT}" --data "username=${QBITTORRENT_USER}" --data-urlencode "password=${QBITTORRENT_PASS}" "http://${QBITTORRENT_SERVER}:${QBITTORRENT_PORT}/api/v2/auth/login" | grep -oP '(?!set-cookie:.)SID=.*(?=\;.HttpOnly\;)')
qbt_sid=$(curl -s -k -i --header "Referer: ${QBITTORRENT_SERVER_HTTP_OR_HTTPS}://${QBITTORRENT_SERVER}:${QBITTORRENT_PORT}" --data "username=${QBITTORRENT_USER}" --data-urlencode "password=${QBITTORRENT_PASS}" "${QBITTORRENT_SERVER_HTTP_OR_HTTPS}://${QBITTORRENT_SERVER}:${QBITTORRENT_PORT}/api/v2/auth/login" | grep -oP '(?!set-cookie:.)SID=.*(?=\;.HttpOnly\;)')
return $?
}

qbt_changeport(){
curl -s -i --header "Referer: http://${QBITTORRENT_SERVER}:${QBITTORRENT_PORT}" --cookie "$1" --data-urlencode "json={\"listen_port\":$2,\"random_port\":false,\"upnp\":false}" "http://${QBITTORRENT_SERVER}:${QBITTORRENT_PORT}/api/v2/app/setPreferences" >/dev/null 2>&1
curl -s -k -i --header "Referer: ${QBITTORRENT_SERVER_HTTP_OR_HTTPS}://${QBITTORRENT_SERVER}:${QBITTORRENT_PORT}" --cookie "$1" --data-urlencode "json={\"listen_port\":$2,\"random_port\":false,\"upnp\":false}" "${QBITTORRENT_SERVER_HTTP_OR_HTTPS}://${QBITTORRENT_SERVER}:${QBITTORRENT_PORT}/api/v2/app/setPreferences" >/dev/null 2>&1
return $?
}

qbt_checksid(){
if curl -s --header "Referer: http://${QBITTORRENT_SERVER}:${QBITTORRENT_PORT}" --cookie "${qbt_sid}" "http://${QBITTORRENT_SERVER}:${QBITTORRENT_PORT}/api/v2/app/version" | grep -qi forbidden; then
if curl -s -k --header "Referer: ${QBITTORRENT_SERVER_HTTP_OR_HTTPS}://${QBITTORRENT_SERVER}:${QBITTORRENT_PORT}" --cookie "${qbt_sid}" "${QBITTORRENT_SERVER_HTTP_OR_HTTPS}://${QBITTORRENT_SERVER}:${QBITTORRENT_PORT}/api/v2/app/version" | grep -qi forbidden; then
return 1
else
return 0
Expand Down Expand Up @@ -164,6 +164,7 @@ while read -r var; do
done << EOF
QBITTORRENT_SERVER
QBITTORRENT_PORT
QBITTORRENT_SERVER_HTTP_OR_HTTPS
QBITTORRENT_USER
QBITTORRENT_PASS
VPN_GATEWAY
Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ services:
# - QBITTORRENT_PORT=8080
# - QBITTORRENT_USER=admin
# - QBITTORRENT_PASS=adminadmin
# - QBITTORRENT_SERVER_HTTP_OR_HTTPS=http
# - VPN_GATEWAY=
# - VPN_CT_NAME=gluetun
# - VPN_IF_NAME=tun0
Expand All @@ -93,4 +94,4 @@ services:
# ipam:
# config:
# - subnet: 172.16.0.0/24
# gateway: 172.16.0.254
# gateway: 172.16.0.254