Project

General

Profile

[Solved] URL and port redirection

Added by flagada15 over 15 years ago

Hi all !
Sorry if this is a newbie question ^^

I am using lighttpd 1.4.23-1 on a DNS323 NAS Server and have a question about url redirection.
I tried to find the solution by myself but it doesn't work at all...

On this NAS server, in addition of the lighttpd web server I have several web applications on several port running. To access them I type my IP address and the port number (xxx.xxx.xxx.xxx:81 for example).
Now I would like to access them by typing something like xxx.xxx.xxx.xxx/app1 which correspond to xxx.xxx.xxx.xxx:81 in order to use only the port 80 from internet.
Do you think this is possible with lighttpd and which module shall I use (mod_proxy, mod_redirect, ...)?

Thank you for all and sorry for my bad English ;o)
Fred


Replies (4)

RE: URL and port redirection - Added by flagada15 over 15 years ago

I try with the mod_proxy and the mod_rewritting with the following conf :
$HTTP["url"] =~ "^/admin/" {
proxy.server = ( "" =>
( "" =>
("host" => "127.0.0.1", "port" => 81)
)
)
}
url.rewrite = (
"^/admin/?(.*)" => "/$1",
)
First the proxy if the url end by "/admin/" and then the rewritting in order to suppress the "/admin/"
It's nice but it doesn't work :(

Do you have an idea of why ?

RE: URL and port redirection - Added by flagada15 over 15 years ago

Hi !
Nobody can help me? :(

RE: URL and port redirection - Added by flagada15 over 15 years ago

OK so as I don't find the solution by myself or on the forum I made an alternative solution by create several redirection on "no-ip.com".
Then with "mod_proxy" I can redirect each host on a different port.

This is not really what I wanted to do but at least it works...

Here is the code just in case :
$HTTP["host"] == "www.exampleadmin.org" {
proxy.server = ( "" =>
( "" =>
("host" => "127.0.0.1", "port" => 81)
)
)
}

bye

RE: RE: URL and port redirection - Added by denk_mal almost 10 years ago

I know this thread is over 5 years old but I came over google here ;-)

There is a simple solution for doing a redirect from an url to another (web)service with a different port on the same machine:

$HTTP["url"] =~ "^/rasppi-mon" {
  $HTTP["host"] =~ ".*" {
    url.redirect = ( "^/(.*)" => "http://%0:8888" )
    url.redirect-code = 302
  }
}

This example will redirect <domain>/rasppi-mon to <domain>:8888

    (1-4/4)