aelkz
aelkz

Reputation: 1875

Tyk gateway with Nginx and Apache Tomcat 8 (ubuntu 14.04)

Just wondering what I am missing here when trying to create an API with Tyk Dashboard.

My setup is:

Nginx > Apache Tomcat 8 > Java Web Application > (database)

Nginx is already working, redirecting calls to apache tomcat at default port 8080.

Example: tomcat.myserver.com/webapp/get/1 200-OK

I have setup tyk-dashboard and tyk-gateway previously as follows using a custom node port 8011:

Tyk dashboard:

$ sudo /opt/tyk-dashboard/install/setup.sh --listenport=3000 --redishost=localhost --redisport=6379 --mongo=mongodb://127.0.0.1/tyk_analytics --tyk_api_hostname=$HOSTNAME --tyk_node_hostname=http://127.0.0.1 --tyk_node_port=8011 --portal_root=/portal --domain="dashboard.tyk-local.com"

Tyk gateway:

/opt/tyk-gateway/install/setup.sh --dashboard=1 --listenport=8011 --redishost=127.0.0.1 --redisport=6379 --domain=""

/etc/hosts already configured (not really needed):

127.0.0.1 dashboard.tyk-local.com
127.0.0.1 portal.tyk-local.com       

Tyk Dashboard configurations (nothing special here):

What URI I suppose to call? Is there any setup I need to add in Nginx?

  1. myserver.com/foo 502 nginx
  2. myserver.com:8011/foo does not respond
  3. foo.myserver.com 502 nginx

(everything is running under the same server)

SOLVED:

Tyk Gateway configuration was incorrect. Needed to add --mongo and remove --domain directives at setup.sh :

/opt/tyk-gateway/install/setup.sh --dashboard=1 --listenport=8011 --redishost=localhost --redisport=6379 --mongo=mongodb://127.0.0.1/tyk_analytics

So, calling curl -H "Authorization: null" 127.0.0.1:8011/foo I get:

{                                                                                                                                                                                                                                         
    "error": "Key not authorised"                                                                                                                                                                                                         
}

Upvotes: 1

Views: 564

Answers (1)

Oluwaseye Ayinla
Oluwaseye Ayinla

Reputation: 11

I am not sure about the /foo path. I think that was previously what the /hello path is. But it appears there is a key not authorized issue. If the call is made using the Gateway API, then the secret value may be missing. It is required when making calls to the gateway (except the hello and reload paths)

x-tyk-authorization: <your-secret>

However, since there is a dashboard present, then I would suggest using the Dashboard APIs to create the API definition instead.

Upvotes: 0

Related Questions