How to Install Ansible AWX with Nginx Reverse Proxy on Ubuntu 18.04

AWX is a free and open source version of the Ansible Tower codebase that can be used to manage Ansible playbooks, inventories and schedule jobs. AWX is also a community project by Red Hat Inc that allows you to control your Ansible project in IT environments. It provides web based inetrface that allows you to manage all your automation tasks from the central location. With this tool, you can set up servers in local and remote infrastructures. You can also perform a wide variety of other configuration tasks such as change the application configuration, start and stop services and install/update applications.

In this tutorial, we will explain how to Install Ansible AWX with Nginx as a reverse proxy on an Ubuntu 18.04 server.


  • A cloud server running Ubuntu 18.04.
  • A valid domain name set up on your server.
  • A root password on your server.

Getting Started

Before starting, it is recommended to update your server with the latest version. You can update it with the following command:
# apt-get update -y
# apt-get upgrade -y

Once your server is updated, restart your server to apply all the changes.

Install Docker and Ansible

Next, you will need to install Docker and Ansible to your server. By default, the latest version of Docker is not available in the Ubuntu 18.04 repository, so you will need to add the Docker repository to your server.

First, download and add Docker CE GPG key with the following command:
# wget
# apt-key add gpg

Next, add the Docker CE repository to APT with the following command:
# nano /etc/apt/sources.list.d/docker.list
Afterwards, add the following line:

deb [arch=amd64] xenial stable

Save and close the file when you are finished.

Then, update the repository and install Docker with the following command:
# apt-get update -y
# apt-get install docker-ce ansible -y

Once the installation has been completed, you can check the status of Docker with the following command:
# systemctl status docker

You should see the following output:

    • docker.service – Docker Application Container Engine

Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled) Active: active (running) since Fri 2019-06-14 07:21:01 CDT; 1min 48s ago Docs: Main PID: 2002 (dockerd) Tasks: 10 Memory: 28.3M CGroup: /system.slice/docker.service └─2002 /usr/bin/dockerd -H fd:// –containerd=/run/containerd/containerd.sock Jun 14 07:20:59 dockerd[2002]: time=”2019-06-14T07:20:59.845688014-05:00″ level=info msg=”pickfirstBalancer…e=grpc Jun 14 07:20:59 dockerd[2002]: time=”2019-06-14T07:20:59.846116992-05:00″ level=info msg=”pickfirstBalancer…e=grpc Jun 14 07:21:00 dockerd[2002]: time=”2019-06-14T07:21:00.132179383-05:00″ level=info msg=”Graph migration t…conds” Jun 14 07:21:00 dockerd[2002]: time=”2019-06-14T07:21:00.133144229-05:00″ level=info msg=”Loading container…tart.” Jun 14 07:21:01 dockerd[2002]: time=”2019-06-14T07:21:01.135427275-05:00″ level=info msg=”Default bridge (d…dress” Jun 14 07:21:01 dockerd[2002]: time=”2019-06-14T07:21:01.475398667-05:00″ level=info msg=”Loading containers: done.” Jun 14 07:21:01 dockerd[2002]: time=”2019-06-14T07:21:01.710333840-05:00″ level=info msg=”Docker daemon” co…8.09.6 Jun 14 07:21:01 dockerd[2002]: time=”2019-06-14T07:21:01.710574644-05:00″ level=info msg=”Daemon has comple…ation” Jun 14 07:21:01 systemd[1]: Started Docker Application Container Engine. Jun 14 07:21:01 dockerd[2002]: time=”2019-06-14T07:21:01.910369983-05:00″ level=info msg=”API listen on /va….sock”

Hint: Some lines were ellipsized, use -l to show in full.


Install Required Dependencies

Next, you will need to install some required dependencies like, Python pip, nodejs, npm and docker-compose to your server.

First, install nodejs npm python-pip with the following command:
# apt-get install python-pip nodejs npm -y

Next, upgrade the npm to the latest version with the following command:
# npm install npm --global

Next, install docker-compose and docker-py using the following command:
# pip install docker-compose==1.9.0
# pip install docker-py

Once you have done this, all the dependencies will be installed. You can proceed to the next step.

Download and Install AWX

Next, you will need to download the latest version of AWX from the Git repository. You can download it with the following command:
# git clone --depth 50

You should see the following output:

Cloning into 'awx'...
remote: Enumerating objects: 9487, done.
remote: Counting objects: 100% (9487/9487), done.
remote: Compressing objects: 100% (4466/4466), done.
remote: Total 9487 (delta 5863), reused 7053 (delta 4875), pack-reused 0
Receiving objects: 100% (9487/9487), 12.25 MiB | 8.50 MiB/s, done.
Resolving deltas: 100% (5863/5863), done.

Next, you will need to generate a secret key for AWX. You can do it with the following command:
# pwgen -N 1 -s 30

Again, you should see the following output:


Next, change the directory to awx/installer and modify inventory file:

# cd awx/installer/
# nano inventory

Make the following changes:


Save and close the file when you are finished.

Next, install the AWX application with the following command:
# ansible-playbook -i inventory install.yml

This command will download docker images and create a new postgresql, memcached, rabbitmq, the awx web-application, and the awx task containers.

Wait for some time to finish the installation. Then, run the following command to see the created containers with the following command:
# docker ps

You should see all the containers in the following output:

"/tini -- /bin/sh ..."


"/tini -- /bin/sh ...">8052/tcp

11211/tcp memcached
4369/tcp, 5671-5672/tcp, 25672/tcp rabbitmq
 5432/tcp  postgres

Once you have thiss done, you can proceed to the following step.

Configure Nginx as a Reverse Proxy for AWX

AWX application is now installed and running on port 8000. Next, you will need to configure Nginx as a reverse proxy. So you can access AWX using port 80.

To do so, first install Nginx with the following command:
# apt-get install nginx -y

Once the Nginx has been installed, you will need to create an Nginx virtual host file for AWX. You can create it with the following command:
# nano /etc/nginx/sites-available/awx.conf

Add the following lines:

server {
listen 80;
access_log /var/log/nginx/awx.access.log;
error_log /var/log/nginx/awx.error.log;

location / {
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://localhost:8000/;

Save and close the file, when you are finished.

Then, activate the AWX virtual host with the following command:
# ln -s /etc/nginx/sites-available/awx.conf /etc/nginx/sites-enabled/

Next, check the Nginx for any syntax error with the following command:
nginx -t

You should see the following output:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Finally, restart Nginx service to apply all the changes with the following command:
# systemctl restart nginx

Access AWX Web Interface

AWX is now installed and configured, it’s time to access AWX web interface.

Open your web browser and type the URL You will be redirected to the AWX login page as shown below:

Now, provide your admin username and password which you have specified in the inventory file. Then, click on the SIGN IN button. You will be redirected to the AWX dashboard page:

Congratulations! You have successfully installed and setup Ansible AWX on your Ubuntu 18.04 server 🙂 You can now manage your IT infrastructure from the central location.

To write a comment on this article, fill out the form below. Fields marked with an asterisk (*) are required.