I am trying to configure an Ubuntu Docker container that runs the HTTP Node.js application on port 9000. To mimic the configuration of the work environment, I would also like to run Apache as a simple reverse proxy within the container that forwards this application from, say, port 80 (which I expose to a big bad world).
I managed to configure the Node.js application container, and I can install and configure Apache in my Dockerfile ; but I'm not at all new to creating a reverse proxy server, so despite the fact that Apache, of course, starts, it is not a proxy server.
My Dockerfile looks something like this:
# DOCKER-VERSION 1.3.0 FROM ubuntu:12.04 # Install and set up Apache as a reverse proxy RUN apt-get -y install apache2 libapache2-mod-proxy-html COPY apache2.conf /etc/apache2/app.conf RUN cat /etc/apache2/app.conf >> /etc/apache2/apache2.conf RUN service apache2 start # Install and set up Node.js and bundle app # ...This works... EXPOSE 80 CMD ["./start-app.sh"]
... where apache2.conf I add to /etc/apache2/apache2.conf :
ServerName localhost LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so LoadModule headers_module /usr/lib/apache2/modules/mod_headers.so LoadModule deflate_module /usr/lib/apache2/modules/mod_deflate.so <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass / http:
I run this image using the following command:
docker run -p 80:80 -p 81:9000 -d IMAGE
I expect the switch to http://$DOCKER_HOST (i.e. the root) will be picked up by Apache and redirected to localhost:9000 (i.e. my application) in the container. (If I go to http://$DOCKER_HOST:81 , I will immediately attach to this application, just to prove that it works and works. It works.) I suspect that the problem is not with the Docker at all, but with the Apache configuration .
source share