Docker – Lighttpd and Discourse (Docker): configuring mod_proxy

dockerlighttpdmod-proxyPROXY

I have trouble configuring Lighttpd to serve the various services hosted on my server.
Lighttpd acts as a front, and I have several DNS records, each for a different subdomain, redirecting to the same machine.

The goal is to dispatch those requests by host to the various other web servers.

In particular, Discourse is set up as a Docker container. The embedded Nginx listens on port 80 of the container, which is mapped to port 3080 of the server via Docker:

$ docker ps
CONTAINER ID        IMAGE                          COMMAND                CREATED             STATUS              PORTS                                                                                                                              NAMES
7b115219788e        local_discourse/app:latest     "/sbin/runit"          11 weeks ago        Up 8 weeks          0.0.0.0:3022->22/tcp, 0.0.0.0:3080->80/tcp 

I enabled mod_proxy on Lighttpd, and here is the configuration:

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

server.document-root        = "/var/www"
server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
server.errorlog             = "/var/log/lighttpd/error.log"
server.pid-file             = "/var/run/lighttpd.pid"
server.username             = "www-data"
server.groupname            = "www-data"
server.port                 = 80


index-file.names            = ( "index.php", "index.html", "index.lighttpd.html" )
url.access-deny             = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

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

# default listening port for IPv6 falls back to the IPv4 port
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"

$HTTP["host"] =~ "discourse.mydomain.com" {
    proxy.debug = 1
    proxy.server  = ( "" => ( "discourse" => ( "host" => "127.0.0.1", "port" => 3080, "fix-redirects" => 1 )))
}

I can tell the calls are getting somewhere, because the logs tell me so:

2014-11-17 21:15:55: (mod_proxy.c.1144) proxy - start
2014-11-17 21:15:55: (mod_proxy.c.1185) proxy - ext found
2014-11-17 21:15:55: (mod_proxy.c.1319) proxy - found a host 127.0.0.1 3080
2014-11-17 21:15:55: (mod_proxy.c.398) connect delayed: 10
2014-11-17 21:15:55: (mod_proxy.c.1000) proxy: fdevent-out 1
2014-11-17 21:15:55: (mod_proxy.c.1029) proxy - connect - delayed success
2014-11-17 21:15:55: (mod_proxy.c.969) proxy: fdevent-in 4
2014-11-17 21:15:55: (mod_proxy.c.667) proxy - have to read: 521
2014-11-17 21:15:55: (mod_proxy.c.969) proxy: fdevent-in 4
2014-11-17 21:15:55: (mod_proxy.c.667) proxy - have to read: 0

Yet, all I have when I go to discourse.redacted.com is a blank page – not a 404 error, mind you.

Am I missing something obvious?

Are there other logs I could pull?

Extra info: calling discourse.redacted.com:3080 works and gets me there.

Best Answer

Have you tried this:

proxy.server  = ("/" =>  (( "host" => "127.0.0.1", "port" => 3080, "fix-redirects" => 1 )))