Proxy¶
For the Giraf project we only have two public IPs that both have a DNS name to
srv.giraf.cs.aau.dk. The firewall settings for those IPs are that only port 80
and port 443
are allowed through and since the different parts of the system
uses other ports, such as port 5000
and 3306
, we need a reverse proxy
to pass the traffic intended for those ports into the Docker Swarm. In the following,
the configuration of the proxy will be elaborated upon.
docker-compose.yml¶
Using the Docker Stack command for deploying to a production environment, a
.yml
file has to be passed to the command.
The file contains at least the following:
1 2 |
|
and can be elaborated with many more options. The file for the proxy is as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
The code specifies a service called proxy that uses the nginx version 1.15.x and that exposes the port 80 and 443 to the network. It has a volume attached where the nginx config folder is mapped into the container. The networks are elaborated in the section about network.
nginx.conf¶
The NGINX can be used for many different purposes and one of them is as a proxy.
The following config is a standard config for a reverse proxy that will enable
all sites in the /etc/nginx/sites-enabled/
folder.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
API¶
The API is file /etc/nginx/sites-enabled/API
specifies where the traffic for
the API is supposed to go once the NGINX server receives it. We can use the
proxy_pass http://API/
inside Docker because it uses static DNS names inside
its network, all traffic for the API will be directed into the API service. This
means that the API can be accessed through http://srv.giraf.cs.aau.dk/API/ on both
port 80
and port 443
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|