Skip to content

Instantly share code, notes, and snippets.

@Hiweus
Created February 7, 2025 20:22
Show Gist options
  • Save Hiweus/a6480698bf56ee4f9858035dd9e02a31 to your computer and use it in GitHub Desktop.
Save Hiweus/a6480698bf56ee4f9858035dd9e02a31 to your computer and use it in GitHub Desktop.
Lightweight api gateway

Api gateway

Create a api gateway and serve ssl

Configuring localhost ssl

mkcert -install
mkcert "*.local.gd" local.gd
services:
# curl https://api.local.gd:8080/api
api:
image: devopsfaith/krakend:2.9.1
ports:
- "8080:8080"
volumes:
- ./krakend.json:/etc/krakend/krakend.json
- ./certs:/certs
backend:
image: busybox
init: true
working_dir: /www
command: httpd -v -f -p 80
ports:
- "8099:80"
volumes:
- ./backend:/www
{
"version": 3,
"tls": {
"public_key": "/certs/fullchain.pem",
"private_key": "/certs/privkey.pem"
},
"name": "My API Gateway",
"timeout": "3000ms",
"cache_ttl": "300s",
"endpoints": [
{
"endpoint": "/api",
"method": "GET",
"backend": [
{
"url_pattern": "/",
"host": ["http://backend"],
"encoding": "json"
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment