How to Install and Configure Consul Server on Ubuntu 18.04

Consul is an open source service discovery tool which is based and built on Golang. It helps you discovering services application requirements like database, queues, and emails. It comes with some awesome features like Service Discovery, Health Check Status, Key/Value Store, Multi-Datacenter Deployment, and Web UI. It is highly available and scalable upto thousands of nodes. It is fully secured and work with large infrastructure adapting modern practices for DevOps.


  • A New Ubuntu 18.04 instance with at least 1 GB RAM
  • A sudo user

Update the System

We recommend you to upgrade all the available packages and update the system, before installing any new package on the system. Execute the following command and it will do the job for you.

sudo apt-get update

Next, you will need to install some required packages such as unzip and tmux if you don’t have installed them already. tmux will help you to access multiple separate terminal sessions inside a single terminal window.

sudo apt-get install unzip sudo apt-get install tmux

Install Nginx

Once the system is updated, you will need to install a web server to access Consul through Web UI from a web browser. Here, we will be installing Nginx web server, you can install Apache web server if you wish. Run the following command to install the Nginx web server.

sudo apt-get install nginx

Download and Install Consul

We have installed all the required dependencies now we are ready to download and install Consul. First, change your current directory to /usr/local/bin using the following command.

cd /usr/local/bin

Now you can download the latest stable version of Consul from the official Consul Download Webpage using wget command. Execute the following command and it will do the job for you.

sudo wget

Next, you will need to unzip the downloaded package and remove the zipped package. Simply, execute the following commands and they’ll do the job for you.

sudo unzip sudo rm -rf

Configure Consul Server

Now we have downloaded the Consul server successfully. Next, you will need to configure the consul server. Create a new directory for configuration files.

cd ~ mkdir -p consul-config/server

Next, create a new configuration file config.json for Consul configuration using any text editor. Here, we are using nano text editor. You can also install it using sudo apt-get install nano command.

sudo nano consul-config/server/config.json

Add the following configuration into the file.

"bootstrap": true,
"server": true,
"log_level": "DEBUG",
"enable_syslog": true,
"datacenter": "server1",
"addresses" : {
"http": ""
"bind_addr": "IP Address",
"node_name": "XX.XX.XX.XX",
"data_dir": "/home/k/consuldata",
"ui_dir": "/home/k/consul-ui",
"acl_datacenter": "server1",
"acl_default_policy": "allow",
"encrypt": "5KKufILrf186BGlilFDNig=="

Make sure to change bind_addr and node_name with your own servers IP or FQDN, then save and close the file.

Next, you will need to create a virtual host in order to configure your web server. So, create a new directory for creating a virtual host for nginx using the following command.

sudo nano /etc/nginx/conf.d/consul.conf

Add the following content into the file.

listen 80 ;
server_name YourServerIP;
root /home/k/consul-ui;
location / {
proxy_set_header   X-Real-IP $remote_addr;
proxy_set_header   Host      $http_host;

Make sure to replace YourServerIP with you actual server IP address or domain name and then save and close the file.

Next, reload the Nginx services for these changes to take effect. Execute the following command to do so. sudo systemctl restart nginx.service

Start the Consul Server

You have successfully installed and configured the consul server with its required dependencies. Now let’s start the Consul server and use it. Run the following command to start its services under the tmux terminal. tmux

consul agent -config-dir ~/consul-config/server -ui-dir ~/consul-ui -bootstrap
true -client=

Now you will see the consul process is running in your terminal, you can leave these processes running in the background by using CTRL+B then hit the D key from the keyboard to detach the terminal.

Now that you have successfully installed Consul, you can proceed further to access Consul web interface. But first we will need to set up our consul agent to access the web ui. Execute the following command and it will do the job for you.

consul agent -dev -ui

The above command will take some time.

Open up your favorite web browser and navigate to the http://YourServerIP/ui. Now you can use the consul server to check the health of your servers and an overview of your services.


In this tutorial, you have learned how to install and configure the Consul server on Ubuntu 18.04. We hope now you have enough knowledge to work with the Consul server. Now you can deploy your new services and overview of those services using Consul.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Nuclear Music Player – An Electron-based Music Streaming Player

Nuclear Music Player is a nice looking free music streaming app that pulls its content from various free sources all over...

Install Light Table Code Editor 0.8.1 on Ubuntu & CentOS

Light Table is the next generation code editor that connects you to your creation with instant feedback. Light Table is...

How to Upgrade to a New Ubuntu Version

Upgrading to a newer version of Ubuntu is a pretty simple and straightforward process. The entire upgrade procedure is...