Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

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.

Caddy2

Everything gets easy when it comes with caddy!

Simple reverse proxy

https://your.domain.tld {
  reverse_proxy * localhost:1300
}

Exclude the /dl/ path, allowing to download files without authentication.

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
  }
}

shared domain with other application, under a directory

https://your.domain.tld {
  #... other path config

  handle_path /cloud/* {
    rewrite * {path}
    reverse_proxy localhost:1300
  }
}

Nginx

with dedicated domain

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;                                                            
    }       
}

Apache2

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>