how to redirect Transmission 1.34 to port 80?

Discussion of the Web Interface for Transmission, formerly known as Clutch. This applies to all version of Transmission
akumajo
Posts: 2
Joined: Tue Oct 07, 2008 6:48 pm

how to redirect Transmission 1.34 to port 80?

Post by akumajo »

Hello

here my current and working setup:
* apache webserver running a website on port 80 (my.site.com)
* transmission webserver running on port 9091 (my.site.com:9091/transmission/web/)

what i want to do is to have access to transmission webserver on port 80 (my.site.com/transmission/web/) but my other webserver must also works on port 80

is possible ? any idea ?

thanks
rb07
Posts: 1400
Joined: Sun Aug 24, 2008 3:14 am

Re: how to redirect Transmission 1.34 to port 80?

Post by rb07 »

Yes, its possible.

You have to configure Apache to do it, and there are many ways to go about it:
  • Define a redirection alias: "Redirect /transmission/web/ http://my.site.com:9091/transmission/web/"
  • Configure and use Apache as proxy, which has the advantage of not having to open the 9091 port to the Internet
  • Use rewrite rule... complex way to control what gets proxied.
The first one just make Apache reply with a redirection to the real link, is a sort of short notation but nothing changes underneath.

The proxy is the more interesting, I use something similar (but with Squid) combined with a ssh tunnel. Since I have Squid, I haven't used Apache's proxy capabilities and don't know much about how to define the correct alias that will make the proxy communicate with transmission-daemon and how does that work with the constant chatter the Web client does.

You'll get a better answer at the Apache user's list (or documentation which you may have already installed, try http://my.site.com/manual).
Azquelt
Posts: 12
Joined: Sun Jul 20, 2008 11:59 am

Re: how to redirect Transmission 1.34 to port 80?

Post by Azquelt »

I've just spent a while finding out how to do this.

If you have transmission running on the same computer as Apache, enable the following modules:

Code: Select all

mod_proxy
mod_proxy_http
Ubuntu and Debian users probably just need to run

Code: Select all

a2enmod proxy
a2enmod proxy_http
Then add the following to your apache config file:

Code: Select all

    ProxyRequests Off
    <Proxy *>
        Order Allow,Deny
        Allow from all
    </Proxy>

    ProxyPass /transmission http://localhost:9091/transmission
    ProxyPassReverse /transmission http://localhost:9091/transmission
This lets Apache work as a reverse proxy, forwarding requests to the transmission directory to localhost:9091 and back again. (I'm not sure that the ProxyPassReverse line is necessary for transmission as it should only be needed if it uses absolute URLs).

You can put any authentication directives in the <Proxy> block

You should then be able to access the transmission interface at http://mydomain/transmission/web

If that's too long for you, you can add a redirect to your apache config like this:

Code: Select all

Redirect permanent /torrents https://mydomain/transmission/web
My whole config file for the ssl side of my web server looks like this:

Code: Select all

NameVirtualHost *:443
<VirtualHost *:443>

    DocumentRoot /var/www/gnat
    SSLEngine on
    SSLOptions +ExportCertData +StrictRequire
    SSLCertificateFile /etc/ssl/certs/apache.crt
    SSLCertificateKeyFile /etc/ssl/private/apache.key
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>

    <Directory /var/www/gnat>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>

    ProxyRequests Off
    <Proxy *>
        Order Allow,Deny
        Allow from all
        AuthType Basic
        AuthName Transmission
        AuthUserFile /etc/apache2/users
        Require user me
    </Proxy>

    Redirect permanent /torrents https://mydomain/transmission/web
    ProxyPass /transmission http://localhost:9091/transmission
    ProxyPassReverse /transmission http://localhost:9091/transmission

    ErrorLog /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/access.log combined
    ServerSignature On

</VirtualHost>
Edit: 2008-12-06 -- Added the bit about loading modules
Edit: 2009-05-10 -- Added where to access the transmission interface after setting up apache
Last edited by Azquelt on Sun May 10, 2009 2:43 pm, edited 2 times in total.
akumajo
Posts: 2
Joined: Tue Oct 07, 2008 6:48 pm

Re: how to redirect Transmission 1.34 to port 80?

Post by akumajo »

thx you, it works !
bluey
Posts: 4
Joined: Tue Nov 11, 2008 1:41 pm

Re: how to redirect Transmission 1.34 to port 80?

Post by bluey »

Well i made the changes but the WebUI is messed up. What could i have made wrong?

Image
pea
Posts: 381
Joined: Tue Apr 17, 2007 11:02 pm
Location: estonia, earth

Re: how to redirect Transmission 1.34 to port 80?

Post by pea »

bluey wrote:Well i made the changes but the WebUI is messed up. What could i have made wrong?
it looks like stylesheet (stylesheets/common.css) is missing or improperly linked or not accessible..
bluey
Posts: 4
Joined: Tue Nov 11, 2008 1:41 pm

Re: how to redirect Transmission 1.34 to port 80?

Post by bluey »

Well the WebUI itself is working as it should. Only the redirection is broken.

here is my vhost config
<IfDefine SSL>
<IfDefine SSL_DEFAULT_VHOST>
<IfModule ssl_module>

Listen 443

<VirtualHost _default_:443>
ServerName mythtv

DocumentRoot /var/www/localhost/htdocs
SSLEngine on
SSLOptions +ExportCertData +StrictRequire
SSLCertificateFile /etc/apache2/ssl/server.crt
SSLCertificateKeyFile /etc/apache2/ssl/server.key

<Directory /var/www/localhost/htdocs>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all

AuthType Basic
AuthName Transmission
AuthUserFile /etc/apache2/users
Require user myself
</Directory>

ProxyRequests Off
<Proxy *>
Order Allow,Deny
Allow from all
AuthType Basic
AuthName Transmission
AuthUserFile /etc/apache2/users
Require user myself
</Proxy>

ProxyPass /transmission http://localhost:9091/transmission/web/
ProxyPassReverse /transmission http://localhost:9091/transmission/web/

ErrorLog /var/log/apache2/error.log

LogLevel warn

CustomLog /var/log/apache2/access.log combined
ServerSignature On

</VirtualHost>


</IfModule>
</IfDefine>
</IfDefine>

# vim: ts=4 filetype=apache
Azquelt
Posts: 12
Joined: Sun Jul 20, 2008 11:59 am

Re: how to redirect Transmission 1.34 to port 80?

Post by Azquelt »

bluey wrote:
ProxyPass /transmission http://localhost:9091/transmission/web/
ProxyPassReverse /transmission http://localhost:9091/transmission/web/
That should be

Code: Select all

ProxyPass /transmission http://localhost:9091/transmission
ProxyPassReverse /transmission http://localhost:9091/transmission
This is important because the web interface also has to be able to access /transmission/rpc to actually communicate with the daemon.
Azquelt
Posts: 12
Joined: Sun Jul 20, 2008 11:59 am

Re: how to redirect Transmission 1.34 to port 80?

Post by Azquelt »

Edited my instructions above to include loading the necessary modules.

Thanks to Abe on IRC.
wereHamster
Posts: 21
Joined: Sun Dec 09, 2007 2:18 pm

Re: how to redirect Transmission 1.34 to port 80?

Post by wereHamster »

For lighty, use the following configuration. You can remove the 'auth' block, I use it so that only authorized users can access the web interface. I know transmisson itself can do authentication, but I'd rather keep all the access control in one place (lighty) instead of scattered all over the web services.

Right now the URL has to be /transmission, it's not easily possible to have the Web UI under a different URL. This will change once ticket 1538 is merged into trunk. Then you'll be able to have the Web UI under any URL you wish.

Code: Select all

server.modules += ( "mod_rewrite", "mod_auth", "mod_proxy" )
url.rewrite-once += ( "^/transmission[/]?$" => "/transmission/web" )

$HTTP["url"] =~ "^/transmission/" {

  auth.backend = "plain"
  auth.backend.plain.userfile = "/var/www/transmission/users"
  auth.require = (
    "" => (
      "method"  => "digest",
      "realm"   => "Transmission Web Interface",
      "require" => "valid-user"
    )
  )

  proxy.server = (
    "" => (
      ( 
        "host" => "127.0.0.1",
        "port" => 9091
      )
    )
  )
}
didrocks
Posts: 3
Joined: Sun May 10, 2009 2:00 pm

Re: how to redirect Transmission 1.34 to port 80?

Post by didrocks »

Hi,

Just tried the same thing, but can't access to transmission webinterface one redirected by the apache proxy :
I go to http://services.mydomain.com and then, get the crendential ask (so, that seems to mean that the redirection is performed succesfully), but then, I got a 404 error…
Accessing directly to the webinterface by http://192.168.0.1:9091 works…

Here is the file used :

Code: Select all

<VirtualHost *:80>

        CustomLog /var/log/apache2/access_stat.log combined
        
        DocumentRoot /home/data/www/www/
        ServerName services.mydomain.com
        Options -Indexes FollowSymLinks

        Alias /munin/ /var/www/munin/
        Alias /munin /var/www/munin/
        <Directory /var/www/munin/>

                Options FollowSymLinks
                AllowOverride None
        
                #authentification
                AuthType Basic
                AuthName "Private stat access"
                AuthUserFile  /home/data/www/.htpasswd
                require valid-user

        </Directory>


        Alias /piwik/ /home/data/www/piwik/
        Alias /piwik /home/data/www/piwik/
        <Directory /home/data/www/piwik/>

                Options -Indexes FollowSymLinks
                AllowOverride None

        </Directory>

        ProxyRequests Off
        <Proxy *>
                Order allow,deny
                Allow from all
        </Proxy>
        ProxyPass /transmission http://localhost:9091/transmission
        ProxyPassReverse /transmission http://localhost:9091/transmission


    ErrorLog /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/access.log combined

</VirtualHost>
I just got this in access.log (nothing in error.log)
192.168.0.254 - - [10/May/2009:16:08:03 +0200] "GET /transmission HTTP/1.1" 401 32 "-" "Mozilla/5.0 (X11; U; Linux i686; fr; rv:1.9.0.10) Gecko/2009042523 Ubuntu/9.04 (jaunty) Firefox/3.0.10"
192.168.0.254 - - [10/May/2009:16:08:03 +0200] "GET /transmission HTTP/1.1" 404 32 "-" "Mozilla/5.0 (X11; U; Linux i686; fr; rv:1.9.0.10) Gecko/2009042523 Ubuntu/9.04 (jaunty) Firefox/3.0.10"
Any idea?
Thanks!
Azquelt
Posts: 12
Joined: Sun Jul 20, 2008 11:59 am

Re: how to redirect Transmission 1.34 to port 80?

Post by Azquelt »

Try accessing http://services.mydomain.com/transmission/web rather than http://services.mydomain.com/transmission

Added this note to the instructions above.
didrocks
Posts: 3
Joined: Sun May 10, 2009 2:00 pm

Re: how to redirect Transmission 1.34 to port 80?

Post by didrocks »

Thanks a lot, I get now the interface, but…

I can't upload torrent file (it does nothing when uploading),
I can see numbers changing (peers, downloading rates) ,
I can interact with existing torrent (pausing/resuming), but I got regularly some "Connection Failed. Could not connect to the server. You may need to reload the page to reconnect." error (let's say, after 10 seconds) and then, no refresh.

Strange, seems that transmission web connexion is dropped by apache?

All works like a charm from the same browser and PC using http://192.168.0.1:9091
didrocks
Posts: 3
Joined: Sun May 10, 2009 2:00 pm

Re: how to redirect Transmission 1.34 to port 80?

Post by didrocks »

Strange, it's working today :)

My apache seems to be happier !
Thanks a lot for this great software.
paf.goncalves
Posts: 1
Joined: Thu Jun 24, 2010 7:11 pm

Re: how to redirect Transmission 1.34 to port 80?

Post by paf.goncalves »

Hi!

I'm trying to configure Apache, my config is:

Code: Select all

        ProxyPass /transmission http://localhost:8080/transmission
        ProxyPassReverse /transmission http://localhost:8080/transmission
It asks for password, i can login, but then it gives error:

Code: Select all

409: Conflict

Your request had an invalid session-id header.

To fix this, follow these steps:

When reading a response, get its X-Transmission-Session-Id header and remember it
Add the updated header to your outgoing requests
When you get this 409 error message, resend your request with the updated header
This requirement has been added to help prevent CSRF attacks.

X-Transmission-Session-Id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Did this hapended with any of you ?
Post Reply