Installing Discourse alongside Apache

(Cedric) #1


I have just decided to move to discourse recently, I have purchased a 1Gb hosting solution from DigitalOcean and started installing everything. My main “issue” is that on my droplet I will have Apache running on port 80 (for other parts of my website).

This being said I went through the installation of Discourse, the only exception being that - before bootstraping - I modified the app.yml configuraton file as this in order for docker to listen on port 8090.


  • “8090:80”

Then started docker. Everything seems fine as when I look at the ports usage I get

tcp6 0 0 [::]:8090 [::]:* LISTEN 10558/docker-proxy

But strangely, if I type myhostaddress:8090, I get a connection refused.

I then went to configure an apache website in sites-enabled

<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName myforumaddress
ProxyPass / http://localhost:8090/
ProxyPassReverse / http://localhost:8090/

Then I try to access myforumaddress I get an error 502 and the following in Apache logs

[Sat Feb 27 01:17:47.966825 2016] [proxy_http:error] [pid 11117] (104)Connection reset by peer: [client] AH01102: error reading status line from remote server localhost:8090
[Sat Feb 27 01:17:47.966979 2016] [proxy:error] [pid 11117] [client] AH00898: Error reading from remote server returned by /

Any idea on what’s wrong?


Do you have the correct modules loaded for the proxy pass?

(Cedric) #3

I have all the following modules enabled. I assume this is ok?

Loaded Modules:
core_module (static)
so_module (static)
watchdog_module (static)
http_module (static)
log_config_module (static)
logio_module (static)
version_module (static)
unixd_module (static)
access_compat_module (shared)
alias_module (shared)
auth_basic_module (shared)
authn_core_module (shared)
authn_file_module (shared)
authz_core_module (shared)
authz_host_module (shared)
authz_user_module (shared)
autoindex_module (shared)
deflate_module (shared)
dir_module (shared)
env_module (shared)
filter_module (shared)
mime_module (shared)
mpm_prefork_module (shared)
negotiation_module (shared)
php5_module (shared)
proxy_module (shared)
proxy_balancer_module (shared)
proxy_http_module (shared)
setenvif_module (shared)
slotmem_shm_module (shared)
socache_shmcb_module (shared)
ssl_module (shared)
status_module (shared)


I’m honestly not sure which ones are necessary for discourse I have a few more listed:

proxy_module proxy_ajp_module proxy_balancer_module proxy_connect_module proxy_http_module

Try the proxy_connect

(Cedric) #5

I tried this but no change… and proxy_ajp_module does not exist


Do you have ModSecurity installed by chance? If so check the log.

(Cedric) #7

I just installed it and found the following :slightly_smiling:

HTTP/1.1 502 Proxy Error
Content-Length: 467
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=iso-8859-1

<title>502 Proxy Error</title>
<h1>Proxy Error</h1>
<p>The proxy server received an invalid
response from an upstream server.<br />
The proxy server could not handle the request <em><a href="/">GET&nbsp;/</a></em>.<p>
Reason: <strong>Error reading from remote server</strong></p></p>
<address>Apache/2.4.7 (Ubuntu) Server at MYDISCOURSEADDRESS Port 80</address>

Apache-Error: [file "mod_proxy_http.c"] [line 1302] [level 3] [status 20014] AH01102: error reading status line from remote server %s:%d
Apache-Error: [file "proxy_util.c"] [line 382] [level 3] AH00898: %s returned by %s
Apache-Handler: proxy-server
Stopwatch: 1456562520548123 3554 (- - -)
Stopwatch2: 1456562520548123 3554; combined=105, p1=12, p2=88, p3=1, p4=1, p5=3, sr=0, sw=0, l=0, gc=0
Response-Body-Transformed: Dechunked
Producer: ModSecurity for Apache/2.7.7 (
Server: Apache/2.4.7 (Ubuntu)


(Cedric) #8

Basically it seems Apache has difficulties contacting Docker… Any idea why?

And generally speaking, is this configuration the right way to proceed?

(Cedric) #9

I did not do anything… but now things are working. :slightly_smiling:


Like I said I have no clue, there was a ton of weirdness I encountered in the last week when I went through about 200 installs of Discourse. I repeated the exact same steps and had different results on more than a few occasions. Glad you got it working.


Is there an easy guide to Apache+Discourse on Ubuntu or should i just quit and host them separately . I googled aroud there are 4-5 pages with rough instructions.