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 Sep 24, 2021
·
14 revisions
It's a common usage that running Simple Torrent
behind a proxy server.
NOTE: simple-torrent
shouldn't be on SSL 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
}
}
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 /sync {
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 $http_connection;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
}
location / {
proxy_pass http://127.0.0.1:3000;
#proxy_pass http://unix:/run/cloud-torrent/cloud.sock; # use if listening on unixsocket
proxy_http_version 1.1;
proxy_set_header Connection '';
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
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>