Discourse / Docker behind a proxy


(Silver Quettier) #1

I saw a similar question for Apache and Nginx, but found nothing about Lighttpd.

Edit: I’ve tried switching to Haproxy, and it yields the same results.

I have a server hosting several services, and various DNS records redirecting to it. Each record is linked to a subdomain. Discourse is installed on Docker (as per the manual), and container / host port mapping is as follows:

$ docker ps
CONTAINER ID        IMAGE                          COMMAND                CREATED             STATUS              PORTS                                                                                                              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 

Lighttpd has been configured on the host with mod_proxy to redirect all traffic aiming “discourse.mydomain.com” to port 3080:

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 )))
}

Sadly, this doesn’t work. It shows a blank page. However, accessing it through port 3080 directly, and bypassing Lighttpd works fine.

Lighttpd logs shows activity when I try to reach Discourse through it:

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

Do anyone know the correct configuration?
What could I do to debug further?

I have asked StackExchange yesterday, but no ideas there.


(Silver Quettier) #2

Well, it seems no-one knows. The problem is definetly on the Docker / Discourse side, as switching to another proxy solution yields the same result, and all other services are reachable.

I’ll keep you posted. If anyone finds a relevant log file, please tell.


(Silver Quettier) #3

I’m still reasearching why connecting through Haproxy makes Discourse unreachable, but I cannot get meaningful logs.

Are there no access logs in the Discourse container?


#4

You can find the nginx and other logs at /var/discourse/shared/standalone/log/var-log/nginx on the host machine, or wherever you have specified it to in the app.yml :smile: