oktadev / okta-kong-origin-example

Kong Gateway Example with OIDC and Okta
https://developer.okta.com/blog/2017/12/04/use-kong-gateway-to-centralize-authentication
44 stars 22 forks source link

kong behind nginx proxy #7

Closed mteodor closed 5 years ago

mteodor commented 5 years ago

Hi I'm having trouble configuring my service deployment I have an api service that I want to consume X-Userinfo from kong I've followed this instructions and successfully configured kong and my service in case when request to http://localhost:8000 is made Now I want to make nginx conf so that service is available at registred hostname

so I have nginx conf

server {
        listen 80;
        listen [::]:80;

        server_name my.service.com;

        location / {
                try_files $uri $uri/ =404;
        }
        location /api{
                proxy_pass http://localhost:8000;
        }
}

so when I hit my.service.com/api/v1/someendpoint I got redirected to okta and after succesfull authentication I got redirected to my.service.com/api/v1/someendpoint/?code=xxxxxxxxx and that request fails

/etc/nginx/sites-available# http -f GET localhost:8001/apis/useradm
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Type: application/json; charset=utf-8
Date: Sun, 28 Apr 2019 13:21:17 GMT
Server: kong/0.11.1
Transfer-Encoding: chunked

{
    "created_at": 1556456888476, 
    "http_if_terminated": false, 
    "https_only": false, 
    "id": "8f8ca632-01fc-41fc-8315-df98dce34fbe", 
    "name": "useradm", 
    "preserve_host": false, 
    "retries": 5, 
    "strip_uri": true, 
    "upstream_connect_timeout": 60000, 
    "upstream_read_timeout": 60000, 
    "upstream_send_timeout": 60000, 
    "upstream_url": "http://localhost:8080", 
    "uris": [
        "/"
    ]
}

this is the response i get 'request to the redirect_uri_path but there's no session state found'

do you have any idea what is wrong?

EDIT: finally I have resolved problem with setting session_secret for the plugin and in the nginx-kong.conf set $session_secret secret; in docker-compose.yml for kong

      KONG_NGINX_PROXY_SET: "$$session_secret secret"