This repository has been archived by the owner on Jun 15, 2023. It is now read-only.
forked from jpillora/cloud-torrent
-
Notifications
You must be signed in to change notification settings - Fork 312
ReverseProxy
Preston edited this page Aug 5, 2021
·
14 revisions
It's a common usage that running Simple Torrent
behind a proxy server.
NOTE: simple-torrent
shouldn't be on TLS mode when used with a reverse proxy.
Everything gets easy when it comes with caddy!
https://your.domain.tld {
reverse_proxy * localhost:1300
}
https://your.domain.tld {
@cld not path /dl/*
reverse_proxy @cld localhost:1300
file_server * {
root /srv/http/ #the upper path of the download dir
browse
}
}
https://your.domain.tld {
#... other path config
handle_path /cloud/* {
rewrite * {path}
reverse_proxy localhost:1300
}
}
map $http_upgrade $connection_upgrade {
default upgrade;
'' keep-alive;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name your.domain.tld;
ssl_certificate /usr/local/nginx/ssl/wildcard.crt;
ssl_certificate_key /usr/local/nginx/ssl/wildcard.key;
location / {
proxy_pass http://127.0.0.1:3000;
#proxy_pass http://unix:/run/cloud-torrent/cloud.sock; # use if listening on unixsocket
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
}
}
map $http_upgrade $connection_upgrade {
default upgrade;
'' keep-alive;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name your.domain.tld;
ssl_certificate /usr/local/nginx/ssl/wildcard.crt;
ssl_certificate_key /usr/local/nginx/ssl/wildcard.key;
location / {
# your default site config
}
location /ctorrent/ {
proxy_pass http://127.0.0.1:3000/; # note the trailing slash here, it matters!
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
}
}
Enable the following modules:
a2enmod rewrite
a2enmod proxy
a2enmod proxy_http
a2enmod proxy_wstunnel
The working conf:
<VirtualHost *:80>
# ServerName www.domain2.com
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) ws://127.0.0.1:3000/$1 [P,L]
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:3000/
ProxyPassReverse / http://127.0.0.1:3000/
</VirtualHost>