How to reverse proxy to a Docker container?

Can you use Apache as a reverse proxy?

Yes, you can use Apache as a reverse proxy if you have the right modules installed. The easiest way to install those modules is with the apache2 package, it comes with many modules and can set them up.

But this might not be a good idea, if you want to expose your applications via a service you probably don't want to do a reverse proxy. A better solution would be to install Tomcat as a service. With modjk, it's even possible to configure your webapps (Tomcat) to use an existing Apache server as a reverse proxy. There is a guide on how to setup modjk for your webapp which looks like a good starting point.

Apache HTTPd is a good option as a reverse proxy. There are several things to consider when using this mode of operation: There are several other services that consume websockets, but this is the most "web" - compatible approach (even if it sounds weird if you haven't heard of it before). If you want a more "traditional" HTTP request over a websocket connection you might have to look at other approaches. One option would be to proxy those requests as well, while serving all standard html/css/js.

There are a lot of options out there for how to manage the sessions on this service. Some common approaches are to setup a database for sessions, an XML file, and cookies, or to use a session store that can be accessed via both HTTP and WS connections. A session store can be either an actual application running on a separate service (not recommended), or an in memory store (recommended). In the latter case a database like MySQL or MongoDB is recommended.

Your service should probably provide a standard way of proxying requests to your websocket endpoint, or make it a first class request. For example if you're doing this through Nginx, you might want to use Nginx Plus as a reverse proxy (note: this will add extra latency and overhead, which will make the overall experience less performant, and if you have real time streaming applications on this server, they could be adversely impacted). However, many Nginx config files already have some sort of reverse proxy settings, so you might be able to work that into your server setup as well.

How to reverse proxy to a Docker container?

I have a Docker container running on an EC2 instance that I'd like to access through a browser. It's a Django project with nginx running on port 80. I've already setup a Docker container with the Django app and Nginx installed and running. I'd like to be able to access my website, which is in the container, through the public IP address of my EC2 instance (for testing purposes). So, when I'm accessing the public IP address of the EC2 instance, I should be able to access the site from the container.

How can I reverse proxy so that I can access my site? My initial thought was to create a docker container with an Nginx server running on port 80. This seems to be the most obvious way of doing this. If I do that, I'd expect to be able to access the container through the public IP address of my EC2 instance, but this isn't happening.

Any help would be greatly appreciated. I'm going to suggest that you look into the use of a reverse proxy. You can use something like NGINX or HAProxy to reverse proxy traffic to a container, and then from that container to your application. This will allow you to have a more sophisticated configuration than the simple case you describe.

How to use Apache to redirect to Docker container?

I would like to install and use Apache for serving a web app with a Docker container that's not running with a Dockerfile. What I'm trying to do is this: a client application (ie a C# ASP.NET application) uploads a file through a form submission which then the server accepts the file and creates a zip file from it. The file name matches the URI which then is being delivered back to the client application. This happens because I only have one form submission and a handler so all requests get sent back to the form handler. In a web browser, the URI looks like this:

Now, I could create a zip archive containing my C# app in a file but that seems not flexible and requires a bunch of configuration. What I'd like to do is the following: The client application should be configured to send the request to an apache webserver which internally gets forwarded to the container. There the application should generate the zip file and deliver it to the browser in this URI:
How would I go about this? How would I need to set up my apache server? Is there a sample out there that shows how to deploy a full apache server inside a docker container but forwards requests to a container? There is good information here: Basically, configure your HTTP server to listen to port 443 and rewrite incoming requests. ProxyPass /. ProxyPassReverse /. When you get an actual HTTP request in on the right port (443) it will get rewritten by the proxy directives. In this case, you would get HTTP/1.1 302 Found Content-Length: 0. Location: /testfolder/myzipfilename.

How to proxy a Docker container?

In this tutorial, I'll show you how to use a Docker daemon running as a proxy to a host machine. You'll be able to access Docker services remotely through the proxy and you'll be able to run containers on the host via the proxy as well.

This is great because it means that the Docker user does not need to have access to the host operating system, thus preventing them from accidentally damaging the host OS or running into security issues. If you already have a Docker daemon set up on your machine, you can simply run the command below: You can also try out the tutorial without having to setup a Docker daemon at all by setting your docker host's address in your Docker client (Docker Hub) as the proxy IP address instead: A proxy is useful if your Docker client uses its own IP address or if you want to host a proxy for remote clients. If you want to create a proxy that's only available to you, you can modify the configuration file /etc/docker/daemon.json and uncomment the following line:

You can now edit the file above to create a new Docker proxy. First, make sure to use root to save changes to this file: sudo vim /etc/docker/daemon.

Related Answers

Does docker have an IP?

No-IP is a software package that provides IP address allocation, dynamic DNS update, an...

How to configure NGINX with SSL as a reverse proxy for Jenkins?

In this blog, we'll learn how to setup NGINX reverse proxy in Dock...

What are the two types of proxies?

You can use a reverse proxy for multiple reasons, but mostly it is us...