How to use another web server on the port 80 (like Transmission Remote GUI)

Status
Not open for further replies.

NitroG42

Cadet
Joined
Sep 14, 2011
Messages
1
Hi, I've done this today, so i will show you how to use lighttpd as a web proxy to access another service hosted on another port on you nas (or else).

You just need to open an SSH connexion to your Freenas, and edit the file /etc/local/lighttpd/lighttpd.conf like this:

For this how-to, we will suppose that :
- our nas address is http://mynas.org, and on port 80 there is the freenas gui
- we run the transmission web gui at http://mynas.org:9091/transmission/web (on port 9091)

Very important ! :
mount -uw /

First, uncomment (remove the #) at the line "mod_auth", and "mod_proxy" :
Code:
server.modules              = (
                                "mod_rewrite",
#                               "mod_redirect",
                                "mod_alias",
                                "mod_access",
#                               "mod_trigger_b4_dl",
                                "mod_auth",
#                               "mod_status",
#                               "mod_setenv",
                                "mod_fastcgi",
                                "mod_proxy",
#                               "mod_simple_vhost",
#                               "mod_evhost",
#                               "mod_userdir",
#                               "mod_cgi",
#                               "mod_compress",
#                               "mod_ssi",
#                               "mod_usertrack",
#                               "mod_expire",
#                               "mod_secdownload",
#                               "mod_rrdtool",
                                "mod_accesslog" )

Don't copy the comment that i added ! (you don't need it )
Now, we will do a redirection if a user call the url http://mynas.org/transmission/web :

transmission is the url that will be proxied.
Code:
$HTTP["url"] =~ "^/transmission/" {
  #the auth lines below is used to protect by login and password the access of the transmission gui, if not, everyone can do anything he wants on anyway, you can comment them if you don't want to protect it

  auth.backend = "plain"

 #you need to put the path of a file that will contain the login and password of the #user, on the pattern
#user:password
#user:password
#etc...
  auth.backend.plain.userfile = "/var/www/transmission/users"

  auth.require = (
    "" => (
      "method"  => "digest",
      "realm"   => "Transmission Web Interface",
      "require" => "valid-user"
    )
  )

#Here you set the adress of the hoster. If your service is on another ip, you can change it, same for the port
  proxy.server = (
    "" => (
      ( 
        "host" => "127.0.0.1",
        "port" => 9091
      )
    )
  )
}

Then you need to prevent the gui of Freenas to get the hand on the url of your service (If not, transmission/web will just show an empty freenas gui page)
Code:
url.rewrite-once = (
    "^(/media.*)$" => "$1",
    "^(/freenas/media.*)$" => "$1",
   #this line is only for accessing to the real adress by typing only /transmission instead of /transmission/web
    "^/transmission[/]?$" => "/transmission/web",
    "^(/dojango.*)$" => "$1",
    "^/favicon\.ico$" => "/media/favicon.ico",
    #To prevent it, you need to put a word from the address. It means every word you #put in the red part (change only the "transmission" part !) will be ignored by freenas.
#So it needs that your service isn't named by a page used by freenas (ex : if it is #shutdown, you will probably not be able to shutdown your nas by the gui)
    "^(/(?!(transmission)).*)$" => "/mysite.fcgi$1",
)


It's over, now the very important part is to save your work !
cp /etc/local/lighttpd/lighttpd.conf /conf/base/etc/local/lighttpd/lighttpd.conf
 
Status
Not open for further replies.
Top