Search code examples
apachedockerdiscourse

Discourse Docker and Apache on one server


Hi I have Discourse installed via Docker and Apache server on the same Ubuntu 12.04 server.

Discourse container is exposed to port 81 and Apache is on port 80.

How can I setup Apache to show Apache web like "something.com" and discourse docker on something like "forum.something.com".

I used this for Discourse: https://github.com/discourse/discourse_docker


Solution

  • You can use any reverse proxy to do this.

    You have one container for apache, one container for discourse (or one with both) and you do not expose any ports (do not use -p). However, you might want to use the PORT instruction if you are building the image via a dockerfile.

    Once the containers are running, you should be able to access them via <ip container apache>:80 and <ip container discourse>:81 from the host.

    Now you can start a new container with a reverse proxy. If you used PORT, you can even link the containers (i.e. docker run -link <apache container name>:apache -link <discourse container name>:discourse) in order to have the ips on the env.

    You can use reverse proxies like apache, nginx or hipache.

    When you run the reverse proxy container, you need to specify the -p 0.0.0.0:80:80 in order to have it available form outside the host.

    Example of nginx config for reverse proxy using docker links: https://github.com/creack/prod/blob/master/nginx/nginx.conf#L27