This was created to help expose ports for an ArangoDB container running on a Ubuntu EC2 instance
For this example, let's assume the container we want to expose is called arangodb-instance
, our Nginx instance will be nginx
, and our network will be called reverse-proxy
.
Start by creating our new network.
docker network create reverse-proxy
Next we need to connect our network to the exisitng container we would like to expose.
docker network connect reverse-proxy arangodb-instance
Start our Nginx server and link our network to create the interface for our reverse proxy. We're going to directly port the existing port 8529
through the Nginx port 8529
, so no remapping ports, just apssing through.
docker run -d --name nginx --network reverse-proxy -p 8529:8529 nginx
You don't need to remove the default config file, but we are going to here.
docker exec nginx rm /etc/nginx/conf.d/default.conf
Now we can create a new config file called arango.conf
with the following definition.
server {
listen 8529;
location / {
proxy_pass http://arangodb-instance:8529;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Notice we listen on port 8529
and pass those requests through to the arangodb-instance
listening through http
on port 8529
.
Finally we can add/update the Nginx config file into our nginx container and update.
docker cp ./arango.conf nginx:/etc/nginx/conf.d/arango.conf
docker restart nginx