Gravitee Docker Compose
Setting up Gravitee API Platform Using Docker Compose with Nginx Proxy and SSL
In this guide, we’ll walk through the process of setting up the Gravitee API Management Platform using Docker Compose, Nginx as a reverse proxy, and SSL secured with Certbot on Ubuntu 22.04.
Prerequisites
Ensure the following tools are installed on your system:
Docker
Docker Compose
Nginx
Certbot
OS: Ubuntu 22.04
Installing Docker and Docker Compose
Install Docker
Update existing packages:
sudo apt update
Install prerequisite packages for HTTPS access:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
Add GPG key for the Docker repository:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Add Docker repository to APT sources:
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
5. **Update package list**:
sudo apt update
Install Docker:
sudo apt install docker-ce
Check Docker status:
sudo systemctl status docker
Reference: How to Install Docker on Ubuntu 22.04
Install Docker Compose
Download Docker Compose:
mkdir -p ~/.docker/cli-plugins/ curl -SL https://github.com/docker/compose/releases/download/v2.3.3/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose
Set permissions:
chmod +x ~/.docker/cli-plugins/docker-compose
Check Docker Compose version:
docker compose version
Reference: How to Install Docker Compose on Ubuntu 22.04
Setting Up Gravitee API Management Platform
Create a folder for Gravitee:
mkdir Gravitee cd Gravitee
Download the Docker Compose file:
curl https://raw.githubusercontent.com/gravitee-io/gravitee-docker/master/apim/3.x/docker-compose.yml -o docker-compose.yml
Update the Docker Compose file: Replace
localhost
with your server's public IP address:PORTAL_API_URL=http://<PUBLIC-IP>:8083/portal/environments/DEFAULT MGMT_API_URL=http://<PUBLIC-IP>:8083/management/organizations/DEFAULT/environments/DEFAULT/
Start Gravitee services:
docker compose up -d
Verify containers are running:
docker ps
Access Gravitee Services
API Management:
http://<SERVER-IP>:8084
API Portal:
http://<SERVER-IP>:8085
Default Login Credentials:
Username:
admin
Password:
admin
Reference: Gravitee API Platform Documentation
Setting Up Nginx and Certbot for SSL
Install Certbot and Nginx
Install Certbot:
sudo apt install certbot python3-certbot-nginx
Install Nginx:
sudo apt install nginx -y
Start and verify Nginx:
sudo systemctl start nginx sudo systemctl status nginx
Configure Nginx for Gravitee Services
Navigate to the Nginx
sites-available
directory:cd /etc/nginx/sites-available
Create configuration files: For each service, create a new Nginx configuration file. Replace
portal.domain.com
,gravitee-api.domain.com
, and other domains with your actual domains.
Example: portal.conf
for the Gravitee API Portal (port 8085):
server {
server_name portal.domain.com;
location / {
proxy_pass http://127.0.0.1:8085;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
proxy_connect_timeout 300s;
add_header X-XSS-Protection "1; mode=block";
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header X-Content-Type-Options nosniff;
add_header X-Robots-Tag none;
add_header Content-Security-Policy "upgrade-insecure-requests; ";
autoindex off;
}
}
Repeat for other services:
api.conf
(Management API, port 8083)apim.conf
(API Management UI, port 8084)gateway.conf
(Gateway API, port 8082)
Enable configurations:
ln -s /etc/nginx/sites-available/portal.conf /etc/nginx/sites-enabled/portal.conf ln -s /etc/nginx/sites-available/api.conf /etc/nginx/sites-enabled/api.conf ln -s /etc/nginx/sites-available/apim.conf /etc/nginx/sites-enabled/apim.conf ln -s /etc/nginx/sites-available/gateway.conf /etc/nginx/sites-enabled/gateway.conf
Add Domains to DNS Record
Add DNS records:
portal.domain.com
gravitee-api.domain.com
gateway.domain.com
Obtain SSL Certificates
Run Certbot to obtain SSL certificates for each domain:
sudo certbot --nginx -d portal.domain.com -d gravitee-api.domain.com -d gateway.domain.com
Updating Gravitee Docker Compose Configuration
Stop Gravitee services:
docker compose down
Update
docker-compose.yml
: Replace the URLs with the secured domains:MGMT_API_URL=https://gravitee-api.domain.com/management/organizations/DEFAULT/environments/DEFAULT/ PORTAL_API_URL=https://portal.domain.com/portal/environments/DEFAULT
Restart Gravitee services:
docker compose up -d
Final URLs
Gravitee API Management UI:
https://gravitee.domain.com
Gravitee API Portal UI:
https://portal.domain.com
Gravitee Backend API:
https://gravitee-api.domain.com
Gravitee Gateway API:
https://gateway.domain.com
Your Gravitee API Management Platform is now up and running with secure SSL connections!
Last updated