I need to run Docker side by side with Apache on one server.
Apache currently has a few virtual hosts and Docker has Apache with a specific Python version together with WSGI on it.
I need to set them up together without changing a lot of configuration of virtual hosts which are already there. Basically I need to forward port 80 from container as Apache virtual host or something.
Any ideas?
Best Answer
Sounds like you want something like:
Replace
host.example.com
with the actual host name for the virtual host.Replace
docker.example.com
with the actual host name or IP for the Docker host. If same host, you can uselocalhost
.Replace
1234
with the port which was exported by Docker for the container running your WSGI application.Your WSGI application will have to pay attention to
X-Forwarded-For
andX-Forwarded-Host
headers set by front end Apache when proxying. If your WSGI application can't do that, then might be a good idea to use mod_wsgi instead as it has inbuilt support for dealing with that.The Docker image for mod_wsgi can be found at:
The additional options you would need to supply to mod_wsgi-express are:
If the fix ups aren't done so that the original virtual host name and port are updated in the WSGI environ or by the WSGI application in some other way, the WSGI application when constructing URLs for use in pages and response headers will not generate the correct values.
If you are after more than that, you are going to have to explain it a bit better.
If you want to use the mod_wsgi Docker image, see the Docker Hub page and the blog posts linked from it. Then jump on the mod_wsgi mailing list if need more help.
For more information about the general issues around proxying Apache to backend Python web sites which use mod_wsgi, see: