Is it the target URL in API definition must be publicly reachable?

Hi,

I have a question about the target URL in API definition.

Normally let’s say when we create an API in Tyk, we will put a target URL in the API definition under the core setting. For example, the target URL I am using is pet store io (https://petstore.swagger.io/v2/) which is publicly reachable using browser.

Now, I have a URL, but it is not publicly reachable (like http:localhost:8000; only I can reach it in my browser), which I want to put it in the target URL of my API definition. But when I put this http:localhost:8000 in the target URL in Tyk, and try to call it through Tyk, it could not be reached.

Is it the target URL in the API definition has to be publicly reachable first (like put it in a domain and host)? Is there any way/ setting to configure this http://localhost:8000 in Tyk so that it is reachable when we call it through Tyk? Let’s say I have a bunch of APIs which are only reachable internally (in localhost:some_port_numbers), how to put these APIs into the target URL in Tyk so that they can be reachable?

Regards,

Maan Tarng

Is it the target URL in the API definition has to be publicly reachable first (like put it in a domain and host)?

No, I don’t think it has to be publicly available. I think it is possible to reach a target Url or IP address if you use your local IP address. I also think this depends on your OS or environment. For example, if you are using docker, then you would need to use host.docker.internal.

You do not need your upstream to be publicly accessible. You only need your gateway to be able to access your upstream.

@Olu Thanks for your help and information.

1 Like

@zaid Thanks for your help and information.

1 Like

@Olu May I ask this ‘host.docker.internal’ should be placed in Tyk docker compose file, or my application docker compose file?

Thanks.

Regards,

Maan Tarng

I am not too versed at docker configuration but it should work if you reference it in the target_url of your API definition. More on this thread