1

I have kong locally running on a docker container as below

Dockerfile

FROM kong
USER 0
RUN mkdir -p /kong/declarative/
COPY declarative/kong.yml /kong/declarative/
RUN cp /etc/kong/kong.conf.default /etc/kong/kong.conf
USER kong

and docker-compose

version: "3.8"

networks:
 kong-net:

services:
  kong:
    container_name: kong
    build:
      context: .
      dockerfile: Dockerfile
    restart: unless-stopped
    networks:
      - kong-net
    volumes:
      - ./declarative:/kong/declarative/
    healthcheck:
      test: [ “CMD”, “curl”, “-f”, “http://kong:8000” ]
      interval: 5s
      timeout: 2s
      retries: 15
    environment:
      - KONG_DATABASE=off
      - KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl
      - KONG_PROXY_ACCESS_LOG=/dev/stdout
      - KONG_ADMIN_ACCESS_LOG=/dev/stdout
      - KONG_PROXY_ERROR_LOG=/dev/stderr
      - KONG_ADMIN_ERROR_LOG=/dev/stderr
      - KONG_DECLARATIVE_CONFIG=/kong/declarative/kong.yml
    ports:
      - "8444:8444"
      - "80:8000"
      - "443:8443"

and /kong/declarative/kong.yml

 _format_version: "1.1"
 _transform: true

 services:
 - host: mockbin.org
   name: example_service
   port: 80
   protocol: http
   routes:
   - name: example_route
     paths:
     - /mock
     strip_path: true

I test it by sending a get request to http://127.0.0.1/mock

It loads as below

enter image description here


First question

Why are images not loading while they load on the original website?


Second Question

As you can see I have mounted a volume in the docker-compose file

    volumes:
      - ./declarative:/kong/declarative/

Also note that if I use docker exec kong cat /kong/declarative/kong.yml command, it prints the content of the kong.yml in which I have one path /mock

I now change kong.yml to

 _format_version: "1.1"
 _transform: true

 services:
 - host: mockbin.org
   name: example_service
   port: 80
   protocol: http
   routes:
   - name: example_route
     paths:
     - /mockkkkkk
     - /m
     strip_path: true

note that if I use docker exec kong cat /kong/declarative/kong.yml command, it prints the content of the kong.yml in which I have two path /mockkkkkk and /m

Now

  • I send a request to http://127.0.0.1/mock it still works but it should not
  • I send a request to http://127.0.0.1/mockkkkkk it does not work but
  • I send a request to http://127.0.0.1/m it does not work but

What is the problem?

Amin Ba
  • 1,603
  • 1
  • 13
  • 38
  • Have you checked the ulr and answer of images ? What is the error you get ? – Ôrel May 02 '22 at 06:23
  • For path you need to add `$` check https://stackoverflow.com/questions/69175806/why-kong-access-non-configured-regex-route – Ôrel May 02 '22 at 06:25

0 Answers0