Discourse in a subdomain, Amazon AMI

docker

(Vmayoral) #1

Hi everyone,

I’ve been running Discourse for a while with great results but i decided to change my server so i had to move it to a new machine.

After configuring httpd and a subdomain:

<VirtualHost *:80>
  ServerName erlerobotics.com
  ServerAdmin contact@erlerobot.com

  DocumentRoot /var/www/html

  <Directory /var/www/html>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
  </Directory>

  ErrorLog /var/log/httpd/erlerobotics.com.error.log
  LogLevel warn
  CustomLog /var/log/httpd/erlerobotics.com.access.log combined
</VirtualHost>

<VirtualHost *:80>
  ServerName forum.erlerobotics.com
  ServerAdmin forum@erlerobot.com

  DocumentRoot /var/www/forum

  <Directory /var/www/forum>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
  </Directory>

  ErrorLog /var/log/httpd/forum.erlerobotics.com.error.log
  LogLevel warn
  CustomLog /var/log/httpd/forum.erlerobotics.com.access.log combined
</VirtualHost>

(tested that the subdomain is working with a simple file on it http://forum.erlerobotics.com/index.html).

Copied all the files from /var/discourse to the new server, installed docker and finally bootstrapped and started the container through the launcher script however i can’t get to see my old Discourse but only what is into the subdomain folder (in this case, a simple “Test”).

No matter what i but i keep seeing the index.html of the subdomain.

Am I missing something in my httpd.conf file?.
Thanks in advance,
In the app.yml i’ve got:

expose:
#  - "80:80"   # fwd host port 80   to container port 80 (http)
  - "85:80"   # fwd host port 80   to container port 80 (http)
  - "2222:22" # fwd host port 2222 to container port 22 (ssh)

so i was expecting something to show up if I type http://forum.erlerobotics.com:85


(Vmayoral) #2

For the record, these are the two sources i used to install, setup docker in Amazon AMI:

And another piece of information that might help, i have perfect access to the container and the container seems also to be in good shape:

sudo ./launcher enter app
which: no docker.io in (/sbin:/bin:/usr/sbin:/usr/bin)
root@ip-172-31-28-57-app:/# 
root@ip-172-31-28-57-app:/# ping www.google.com
PING www.google.com (173.194.118.81) 56(84) bytes of data.
64 bytes from gru09s09-in-f17.1e100.net (173.194.118.81): icmp_seq=1 ttl=52 time=226 ms
 64 bytes from gru09s09-in-f17.1e100.net (173.194.118.81): icmp_seq=2 ttl=52 time=226 ms
64 bytes from gru09s09-in-f17.1e100.net (173.194.118.81): icmp_seq=3 ttl=52 time=226 ms
64 bytes from gru09s09-in-f17.1e100.net (173.194.118.81): icmp_seq=4 ttl=52 time=226 ms
64 bytes from gru09s09-in-f17.1e100.net (173.194.118.81): icmp_seq=5 ttl=52 time=226 ms
^C
--- www.google.com ping statistics ---

(Khoa Nguyen) #3

The problem is your can’t have two apps listen for the same port at the same time. And your apache configuration is totally wrong. There is no /var/www/forum folder.


(Vmayoral) #4

@thangngoc89 thanks for your reply. Mind walking me through the changes needed to fix it?

As far as i undertand the mapping performed in the app.yml file avoids having two apps listening to port 80.
/var/www/forum is where my subdomain is located and where currently i have access to. Shall I delete the VirtualHost entry for the subdomain in the httpd.conf file?


(Vmayoral) #5

@thangngoc89 your words were enought to get into the right route. Much appreciated.
I’m living here the solution that worked for me along a small description of my problem:

Although i had mapped ports in the app.yml file of the docker applications, the apache server was not redirecting properly and a proxy line in the VirtualHost had to be set up. The following configuration did it:

<VirtualHost *:80>
  ServerName erlerobotics.com
  ServerAdmin contact@erlerobot.com

  DocumentRoot /var/www/html

  <Directory /var/www/html>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
  </Directory>

  ErrorLog /var/log/httpd/erlerobotics.com.error.log
  LogLevel warn
  CustomLog /var/log/httpd/erlerobotics.com.access.log combined
</VirtualHost>

<VirtualHost *:80>
  ServerName forum.erlerobotics.com
  ServerAdmin forum@erlerobot.com

  DocumentRoot /var/www/forum

  ProxyPreserveHost On
  ProxyRequests Off

  ProxyPass / http://localhost:85/
  ProxyPassReverse / http://localhost:85/

  <Directory /> 
  	Options FollowSymLinks
	AllowOverride All
  </Directory>
  <Directory /var/www/forum>
 	Options Indexes FollowSymLinks MultiViews
        AllowOverride all
        Order allow,deny
        allow from all
  </Directory>

  ErrorLog /var/log/httpd/forum.erlerobotics.com.error.log
  LogLevel warn
  CustomLog /var/log/httpd/forum.erlerobotics.com.access.log combined
</VirtualHost>


(Sam Saffron) #6

You are going to have to set

DISCOURSE_RELATIVE_URL_ROOT

Also fronting with apache requires a lot of ninja configurations, so unless you understand what evented apache means I would strongly urge you to simply use nginx.


(Jens Maier) #7

One of these days I should really put together a howto for using Apache as a frontend proxy. Anyway, there’s not too much “ninja” config involved:

  1. Make sure Apache uses the event MPM. This depends somewhat on how you’ve installed Apache. (Gentoo users can set APACHE2_MPMS="event" in their make.conf.)
  2. Crank AsyncRequestWorkerFactor up to 20ish.