Skip to content

Instantly share code, notes, and snippets.

@Hiweus
Created February 7, 2025 20:22
Show Gist options
  • Select an option

  • Save Hiweus/a6480698bf56ee4f9858035dd9e02a31 to your computer and use it in GitHub Desktop.

Select an option

Save Hiweus/a6480698bf56ee4f9858035dd9e02a31 to your computer and use it in GitHub Desktop.

Revisions

  1. Hiweus created this gist Feb 7, 2025.
    10 changes: 10 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    # Api gateway

    Create a api gateway and serve ssl

    ## Configuring localhost ssl

    ```shell
    mkcert -install
    mkcert "*.local.gd" local.gd
    ```
    20 changes: 20 additions & 0 deletions docker-compose.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    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

    23 changes: 23 additions & 0 deletions krakend.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    {
    "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"
    }
    ]
    }
    ]
    }