Hi James,
Thank you! I was reading this one:
https://tyk.io/docs/tyk-api-gateway-v-2-0/installation-options-setup/install-tyk-on-ubuntu/
I still don’t say I’d understand the logic behind the configuration, but this is definitely more helpful.
Now I have the gateway running at 127.0.0.1:8000, and there’s the dashboard too.
I have no idea if the gateway is working now correctly or not:
$ sudo service tyk-gateway status
tyk-gateway start/running, process 27115
/var/log/tyk-gateway.stdout and /var/log/tyk-gateway.stderr are empty.
I defined 3 apis on the dashboard (A,B and C in the example below).
When I try this:
$ curl
-H "x-tyk-authorization: 352d20ee67be67f6340b4c0605b044b7"
-s -H "Content-Type: application/json"
-X GET http://127.0.0.1:8000/tyk/health/?api_id=68917538a89c4ec9580cab4046a65a3e
The result is:
{"status":"error","error":"Health checks are not enabled for this node"}
Which suggests, that the API is working.
But if I call curl to create a token I don’t get any response or output:
$ curl
-H "x-tyk-authorization: 352d20ee67be67f6340b4c0605b044b7"
-s -H "Content-Type: application/json" -X POST -d '{
"allowance":100,
"rate":100,
"per":60,
"expires":-1,
"quota_max":10010,
"quota_renews":1475893670171,
"quota_remaining":10100,
"quota_renewal_rate":2592000,
"access_rights":{
"510424f4d2ff4a4341b3f4197a30ce77":{
"api_name":"A",
"api_id":"510424f4d2ff4a4341b3f4197a30ce77"
},
"20e099b2bbb84efc617c78f527148638":{
"api_name":"B",
"api_id":"20e099b2bbb84efc617c78f527148638"
},
"c3e50c33b0214cc27dc3bbf4c3ac1bdc":{
"api_name":"C",
"api_id":"c3e50c33b0214cc27dc3bbf4c3ac1bdc"
}
}
}' http://127.0.0.1:8000/tyk/keys/create
I simply get no output on stdout. If I use the verbose mode of curl then the answer is:
* Hostname was NOT found in DNS cache
* Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8000 (#0)
> POST /tyk/keys/create HTTP/1.1
> User-Agent: curl/7.35.0
> Host: 127.0.0.1:8000
> Accept: */*
> x-tyk-authorization: 352d20ee67be67f6340b4c0605b044b7
> Content-Type: application/json
> Content-Length: 500
>
* upload completely sent off: 500 out of 500 bytes
* Empty reply from server
* Connection #0 to host 127.0.0.1 left intact
If I try to call the same request from nodejs I get an error:
request to http://127.0.0.1:8000/tyk/keys/create failed, reason: socket hang up
As I could find no detailed docs for the API REST calls I have no idea which parameters are required to create a token, maybe some essential info is missing? In the docs there’s only a sample, or is it there somewhere and I just couldn’t find it? But even if this would be a problem with the parameters, is it normal to “hang the cocket” instead of giving back and error message?
my current tyk.conf is the following:
{
"listen_port": 8000,
"secret": "352d20ee67be67f6340b4c0605b044b7",
"template_path": "/opt/tyk-gateway/templates",
"tyk_js_path": "/opt/tyk-gateway/js/tyk.js",
"use_db_app_configs": false,
"app_path": "/opt/tyk-gateway/apps",
"middleware_path": "/opt/tyk-gateway/middleware",
"storage": {
"type": "redis",
"host": "localhost",
"port": 6379,
"username": "",
"password": "",
"database": 0,
"optimisation_max_idle": 2000,
"optimisation_max_active": 4000
},
"enable_analytics": false,
"analytics_config": {
"type": "csv",
"csv_dir": "/tmp",
"mongo_url": "",
"mongo_db_name": "",
"mongo_collection": "",
"purge_delay": -1,
"ignored_ips": [],
"normalise_urls": {
"enabled": true,
"normalise_uuids": true,
"normalise_numbers": true,
"custom_patterns": []
}
},
"health_check": {
"enable_health_checks": false,
"health_check_value_timeouts": 60
},
"optimisations_use_async_session_write": true,
"allow_master_keys": false,
"policies": {
"policy_source": "file",
"policy_record_name": "policies"
},
"hash_keys": true,
"suppress_redis_signal_reload": false,
"close_connections": true,
"enable_non_transactional_rate_limiter": true,
"enable_sentinel_rate_limiter": false,
"local_session_cache": {
"disable_cached_session_state": false
},
"uptime_tests": {
"disable": false,
"config": {
"enable_uptime_analytics": false,
"failure_trigger_sample_size": 3,
"time_wait": 300,
"checker_pool_size": 50
}
},
"http_server_options": {
"enable_websockets": true
},
"hostname": "",
"enable_custom_domains": true,
"enable_jsvm": true
}
Thanks,
Gergely