Install Traefik To Host Multiple SSL Websites On Your VPS
Suppose you had deployed several microservices using Docker and you want to connect these microservices to the outside world. You will probably use some reverse proxy solution that will act as a frontend for these microservices. Nginx is the most popular and efficient reverse proxy solution, but it was written before container technology (like Docker) became so popular. Say, for example, you want to remove one of the microservices from the container or change its port, and, as a result, you have to edit the Nginx configuration file to reflect the new container settings. Now, consider another situation where you add, delete, or scale the microservices application several times in a day—now, you’re editing the routes and other settings several times in the reverse proxy configuration file. There’s a need for a new generation of reverse proxy solutions. Traefik is a modern reverse proxy solution written in GO to meet new these new containerized challenges.
“Træfik listens to your service registry/orchestrator API and instantly generates the routes so your microservices are connected to the outside world – without further intervention from your part.” Source: https://Traefik.io/Traefik was developed with containerized technology in mind, which means there’s a lot of new features available in comparison with other reverse proxy solutions. When running, Traefik does the following and more:
- Dynamically updates the configuration and loads it without a restart.
- Load balances requests from the outside world using multiple available algorithms.
- Enables HTTPS for microservices using Let’s Encrypt.
- Provides a clean web UI.
- Supports for WebSocket, HTTP/2, GRPC.
- Provides metrics to Rest, Prometheus, Datadog, Statsd, InfluxDB.
Prerequisites to install Traefik:
- A VPS running Ubuntu 16.04.
- A non-root,
sudo-enabled user. If you only have a
rootuser, see our SSH tutorial for details on creating new users.
- A working Docker installation—for information about how to install Docker, check out our getting started with Docker tutorial
Step 1. Install DockerTo install the Docker use the following command.
The above command will update your system and install the correct version of docker. Enable the docker service and start it.
$ sudo curl -sS https://get.docker.com/ | sh
$ sudo systemctl enable docker $ sudo systemctl start docker
Step 2. Installing non-Dockerized backend applicationsOur first goal is to route a few applications (backend) using Traefik (frontend) without Dockerizing them. To do that, we’ll install Apache and Nginx and configure them to use different ports, as they will act as a backend.
Change the port number to
$ sudo apt-get install apache2
/etc/apache2/ports.confand restart Apache.
Install Nginx and change the port number to
$ sudo vi /etc/apache2/ports.conf $ sudo systemctl restart apache2
8082in the following two files. Then, restart Nginx.
Now both Apache and Nginx will be available in the port number
$ sudo apt-get install nginx $ sudo vi /etc/nginx/sites-available/default $ sudo vi /etc/nginx/sites-enabled/default $ sudo systemctl restart nginx
Step 3. Run Traefik from the binaryTo install
Continue reading this articleSubscribe now
by subscribing to our newsletter.
by subscribing to our newsletter.
Share this post:Reddit Hacker News Facebook Twitter Flipboard
Like what you saw? Subscribe to our weekly newsletter.