Project

General

Profile

How to configure lighttpd to serve a daemon on https://192.168.1.1:9090 as https://192.168.1.1/daemon?

Added by DrTwox about 11 years ago

I have lighttpd v1.4.28 on Ubuntu Server 12.04 serving pages at https://192.168.1.1 on port 443. lighttpd.conf listed below.

On the same server I have another service, accessible at https://192.168.1.1:9090.

I would like to access the service using https://192.168.1.1/daemon

I naively thought I could add the following

$HTTP["url"] =~ "^/daemon" {
    proxy.server = ( "" => ( ( "host" => "192.168.1.1", "port" => 9090 ) ) )
}

to the lighttpd config but accessing https://192.168.1.1/daemon just ends up sending users to https://192.168.1.1:9090/daemon, which is not what I want.

How can I configure lighttpd to transparently serve the page at https://192.168.1.1:9090 as https://192.168.1.1/daemon?

My lighttpd.conf:

server.modules = (
        "mod_access",
        "mod_alias",
        "mod_compress",
        "mod_redirect",
#       "mod_rewrite",
        "mod_proxy",
)

ssl.engine = "enable" 
ssl.pemfile = "/etc/lighttpd/ssl/server.pem" 

server.bind                 = "192.168.1.1" 
#server.port                 = 443
server.use-ipv6             = "disable" 
server.document-root        = "/var/www" 
server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
#server.log_root             = "/var/log/lighttpd/" 
server.errorlog             = "/var/log/lighttpd/error.log" 
server.pid-file             = "/var/run/lighttpd.pid" 
server.username             = "www-data" 
server.groupname            = "www-data" 

index-file.names            = ( "index.php", "index.html",
                                "index.htm", "default.htm",
                               " index.lighttpd.html" )

url.access-deny             = ( "~", ".inc" )

static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

dir-listing.encoding        = "utf-8" 
server.dir-listing          = "disable" 

compress.cache-dir          = "/var/cache/lighttpd/compress/" 
compress.filetype           = ( "application/x-javascript", "text/css", "text/html", "text/plain" )

include_shell "/usr/share/lighttpd/create-mime.assign.pl" 
include_shell "/usr/share/lighttpd/include-conf-enabled.pl" 


Replies (1)

RE: How to configure lighttpd to serve SABnzbd on https://192.168.1.1:9090 as https://192.168.1.1/sabnzbd? - Added by stbuehler about 11 years ago

URL rewriting before mod_proxy is a bad idea; it is very likely all links (in HTTP headers and HTML, CSS, ...) sent from your backend are going to be broken.

Using mod_rewrite won't work in your case, as request handling is restarted after a successful rewrite, and the rewritten URL wouldn't match your conditional anymore.

Usually you'd use a separate vhost for applications that only work in the "root" location.

It looks like you don't have the option with hostnames as you're using an internal ip directly: what is wrong with accessing SABnzbd on its own port in this case? The URL isn't "user-friendly" anyway... (bookmark, mod_redirect, ...)

    (1-1/1)