Trouble configuring my Tyk


#1

Imported Google Group message. Original thread at: https://groups.google.com/forum/#!topic/tyk-community-support/PGBhwwurW54 Import Date: 2016-01-19 21:26:07 +0000.
Sender:[email protected].
Date:Thursday, 1 October 2015 22:45:31 UTC+1.

I tried to create two apis on locahost Tyk

And both have different’s Api_Slug but when i tried to access the second slug always the first respond.

First Api Settings :

Api_slug: second
Target Url: http://10.192.40.28:8095/servicios/hotel_servicio/call/json/listHotel
Listen path: default.

Second Api Settings :

Api_slug: hotel
Target Url: http://10.192.40.28:8091/servicios/call/create
Listen path: default.

No matter what url i test always answer me the first api.


#2

Imported Google Group message.
Sender:Martin Buhr.
Date:Friday, 2 October 2015 04:53:18 UTC+1.

The API slug will only work with the host manager configured.
Have you set up the host manager?
Are you insights QuickStart or a standard install?
Have you tried accessing the API via the listen path and the tyk gateway directly?
Cheers,
Martin


#3

Imported Google Group message.
Sender:Ian Harris.
Date:Friday, 2 October 2015 10:32:24 UTC+1.

Hi Martin,

I’m seeing this issue as well. I’ve two APIs configured under an organisation. I’m trying to access the first but getting the second. I’ve tried accessing with both the api slug and the listen path. There seems to be some issue with how Tyk is handling the path. For my example, the api slug for my first API is “slug” and the listen path is “bd7c97cd650e47dc47f654a2bb74f119”. As you can see from the output below it seems to try to use the second API and just tags the slug/listen path provided onto the listen path of the second API.

Note in this scenario I have the first API configured for token authentication and the second for HMAC. If I change the second to token and add the relevant key to it I get 404 not found errors. If I then remove the slug from the request I get the correct response from the target API - which is httpbin.org.

time=“2015-10-02T09:19:32Z” level=info msg=“Authorization field missing or malformed” origin=“10.156.0.55:34662” path="/810feec25e2b4e7a7b70fbad4d02a74c/slug/ip"
time=“2015-10-02T09:22:42Z” level=info msg=“Authorization field missing or malformed” origin=“10.156.0.55:34947” path="/810feec25e2b4e7a7b70fbad4d02a74c/bd7c97cd650e47dc47f654a2bb74f119/ip"

Any ideas what might be going on here?

Thanks,
Ian.

  • show quoted text -

#4

Imported Google Group message.
Sender:Martin Buhr.
Date:Friday, 2 October 2015 11:09:48 UTC+1.

Hi Ian,

There might be a confusion here as to what the listen_path and the api slug are.

The listen-path is the unique path that the tyk gateway assigns to the API to proxy, this must be unique and is used by the gateway only. To access an API via the listen_path, you need to speak directly to the Tyk Gateway (not the host manager / nginx), so your URL would be:

http://domain.com:3000/{listen_path}/resource/id

For each API, the listen path would be different, for the listen_path you gave above, it would be this:

http://domain.com:3000/bd7c97cd650e47dc47f654a2bb74f119/ip

And the other API would be:

http://domain.com:3000/810feec25e2b4e7a7b70fbad4d02a74c/ip

(I assume both are pointing at httpbin.org)

If you are using the host manager, then the API slug forms part of the domain (note, you’ll need a working domain), so then your path to the API might look like this (notice the different port):

http://domain.com:80/{slug}/ip

OR

http://{slug}.domain.com/ip

Both routes will be generated in the host manager.

So, to re-iterate, the API Slug will only work via NGINX and the listen pah will only work if you speak to the gateway directly.

If NginX is routing to one as a default, then one of your APis is misconfigured (maybe a missing API Slug?), alternatively, if it can’t match anything, I think it defaults to the first thing it finds, which might explain what’s happening to you.

To really get to the bottom of things, you’ll need to see what is in the nginx sites-enabled folder.

Cheers,
Martin

  • show quoted text -

#5

Imported Google Group message.
Sender:Ian Harris.
Date:Friday, 2 October 2015 11:41:42 UTC+1.

Hi Martin,

Hmm… we seem to have a rather serious case of user error occurring here :slight_smile:

I was addressing the wrong base URL (but which resolved to the same IP address). I had started the tykio/tyk-host-manager image with the
“-e DOMAINALIAS=” not set to tyk.docker but was sending requests to {org-slug}.tyk.docker/{api-slug}/{target API path}.

Thanks,
Feeling foolish Ian.

  • show quoted text -

#6

Imported Google Group message.
Sender:Martin Buhr.
Date:Friday, 2 October 2015 11:58:44 UTC+1.

Hi Ian,

Happens all the time - there’s a few moving parts that make it all work in tandem, and they can very easily confuse things :wink:

To be honest, we need to spend a lot more time improving our docs as this kind of jig append too often :-/

Cheers,
Martin


From: Ian Harris [email protected]
Sent: Friday, October 2, 2015 15:41
Subject: Re: Trouble configuring my Tyk.
To: Tyk Community Support [email protected]

  • show quoted text -


You received this message because you are subscribed to the Google Groups “Tyk Community Support” group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web, visit https://groups.google.com/d/msgid/tyk-community-support/68475551-14ba-47d5-858b-9a9a0b78b51e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


#7

Imported Google Group message.
Sender:[email protected].
Date:Friday, 2 October 2015 16:44:52 UTC+1.

Hello Martin.

Yes i have one docker with host manager. https://github.com/lonelycode/tyk-host-manager-docker

all my configuration is automated with this script i found here https://gist.github.com/lonelycode/4f645c4733faaa74d8fd.

Have you tried accessing the API via the listen path and the tyk gateway directly?
yes, and work

the api slug dont : (

  • show quoted text -

#8

Imported Google Group message.
Sender:Martin Buhr.
Date:Friday, 2 October 2015 19:01:05 UTC+1.

Ok, are you using the tyk.docker domain and have you set your local hosts file up to point tyk.docker at your docker IP?

The QuickStart script and docker files are specific for this domain unless you change the donainalias setting in the script.

Cheers,
Martin