Target URL not invoked

I’m trying to setup tyk on a simple service to retrieve user details. But the target service is not getting invoked. What am I missing ?

proxy- GET /users/{id}
custom domain - 127.0.0.1:8080
listen path - /users/

Target - GET /user-service/users/{id}
Target URL - http://127.0.0.1:8888/user-service/

● tyk-gateway.service - Tyk API Gateway
Aug 09 00:43:49 tushar tyk[8849]: time=“Aug 9 00:43:49” level=info msg=“Detected 1 APIs”
Aug 09 00:43:49 tushar tyk[8849]: time=“Aug 9 00:43:49” level=info msg=“Loading API configurations.”
Aug 09 00:43:49 tushar tyk[8849]: time=“Aug 9 00:43:49” level=info msg=“–> Loading API: Users”
Aug 09 00:43:49 tushar tyk[8849]: time=“Aug 9 00:43:49” level=info msg=“----> Custom Domain: 127.0.0.1:8080”
Aug 09 00:43:49 tushar tyk[8849]: time=“Aug 9 00:43:49” level=info msg=“----> Tracking: 127.0.0.1:8080”
Aug 09 00:43:49 tushar tyk[8849]: time=“Aug 9 00:43:49” level=info msg=“----> Checking security policy: Open”
Aug 09 00:43:49 tushar tyk[8849]: time=“Aug 9 00:43:49” level=info msg=“Loading uptime tests…”
Aug 09 00:43:49 tushar tyk[8849]: time=“Aug 9 00:43:49” level=info msg=“Initialised API Definitions”
Aug 09 00:43:49 tushar tyk[8849]: time=“Aug 9 00:43:49” level=info msg=“Gateway started (v2.2.0.1)”
Aug 09 00:43:49 tushar tyk[8849]: time=“Aug 9 00:43:49” level=info msg=“–> Listening on port: 8080”

Since there is no way to attach json, listed below is the API definition exported from dashboard.
{
“id”: “57a7d9d4df7c903948000002”,
“name”: “Users”,
“slug”: “get-user”,
“api_id”: “c19970ae9f0341c97e0d06b47bf4d8b9”,
“org_id”: “57a7d891df7c903948000001”,
“use_keyless”: true,
“use_oauth2”: false,
“use_openid”: false,
“openid_options”: {
“providers”: [],
“segregate_by_client”: false
},
“oauth_meta”: {
“allowed_access_types”: [],
“allowed_authorize_types”: [],
“auth_login_redirect”: “”
},
“auth”: {
“use_param”: false,
“param_name”: “”,
“use_cookie”: false,
“cookie_name”: “”,
“auth_header_name”: “”
},
“use_basic_auth”: false,
“enable_jwt”: false,
“jwt_signing_method”: “”,
“jwt_source”: “”,
“jwt_identity_base_field”: “”,
“jwt_client_base_field”: “”,
“jwt_policy_field_name”: “”,
“notifications”: {
“shared_secret”: “”,
“oauth_on_keychange_url”: “”
},
“enable_signature_checking”: false,
“hmac_allowed_clock_skew”: -1,
“definition”: {
“location”: “header”,
“key”: “x-api-version”
},
“version_data”: {
“not_versioned”: true,
“versions”: {
“Default”: {
“name”: “Default”,
“expires”: “”,
“paths”: {
“ignored”: [],
“white_list”: [],
“black_list”: []
},
“use_extended_paths”: true,
“extended_paths”: {
“ignored”: [],
“white_list”: [
{
“path”: “/users/{id}”,
“method_actions”: {
“GET”: {
“action”: “no_action”,
“code”: 200,
“data”: “”,
“headers”: {}
}
}
}
],
“black_list”: [],
“cache”: [],
“transform”: [],
“transform_response”: [],
“transform_headers”: [],
“transform_response_headers”: [],
“hard_timeouts”: [],
“circuit_breakers”: [],
“url_rewrites”: [],
“virtual”: [],
“size_limits”: [],
“method_transforms”: []
},
“global_headers”: {
“Content-Type”: “application/json”
},
“global_headers_remove”: [],
“global_size_limit”: 0,
“override_target”: “”
}
}
},
“uptime_tests”: {
“check_list”: [],
“config”: {
“expire_utime_after”: 0,
“service_discovery”: {
“use_discovery_service”: false,
“query_endpoint”: “”,
“use_nested_query”: false,
“parent_data_path”: “”,
“data_path”: “”,
“port_data_path”: “”,
“target_path”: “”,
“use_target_list”: false,
“cache_timeout”: 60,
“endpoint_returns_list”: false
},
“recheck_wait”: 0
}
},
“proxy”: {
“preserve_host_header”: false,
“listen_path”: “/users/*”,
“target_url”: “http://127.0.0.1:8888/user-service/”,
“strip_listen_path”: false,
“enable_load_balancing”: false,
“target_list”: [],
“check_host_against_uptime_tests”: false,
“service_discovery”: {
“use_discovery_service”: false,
“query_endpoint”: “”,
“use_nested_query”: false,
“parent_data_path”: “”,
“data_path”: “hostname”,
“port_data_path”: “port”,
“target_path”: “/api-slug”,
“use_target_list”: false,
“cache_timeout”: 60,
“endpoint_returns_list”: false
}
},
“custom_middleware”: {
“pre”: [],
“post”: [],
“response”: []
},
“cache_options”: {
“cache_timeout”: 60,
“enable_cache”: false,
“cache_all_safe_requests”: false,
“cache_response_codes”: [],
“enable_upstream_cache_control”: false
},
“session_lifetime”: 0,
“active”: true,
“auth_provider”: {
“name”: “”,
“storage_engine”: “”,
“meta”: {}
},
“session_provider”: {
“name”: “”,
“storage_engine”: “”,
“meta”: null
},
“event_handlers”: {
“events”: {}
},
“enable_batch_request_support”: false,
“enable_ip_whitelisting”: false,
“allowed_ips”: [],
“dont_set_quota_on_create”: false,
“expire_analytics_after”: 0,
“response_processors”: [],
“CORS”: {
“enable”: false,
“allowed_origins”: [],
“allowed_methods”: [
“GET”
],
“allowed_headers”: [],
“exposed_headers”: [],
“allow_credentials”: false,
“max_age”: 24,
“options_passthrough”: false,
“debug”: false
},
“domain”: “127.0.0.1:8080”,
“do_not_track”: false,
“tags”: [],
“enable_context_vars”: false
}

Hi, are you getting any log message when sending a request to Tyk?

The custom domain is the thing that’s causing the issue - it’s not actually a host name, also remove the port, the port IIIRC is added by Tyk.

tried it. Still getting the same response. 404 not found.
whats IIIRC ?

response from RestClient - 404 page not found
Where should I check logs ? I’m using ubuntu 16.04

It takes 10s for a reload to take effect - you can see that in the logs which are usually in /var/log/upstart on Ubuntu systems.

The 404 is basically the server saying it can’t find the matching path you are looking for, so you may have a configuration problem, e.g. Did you set a host name in your Tyk.conf? Tyk is really strict about things like that.

Is this Tyk Pro or are you using CE?

Is this Tyk Pro or are you using CE?
[Tushar] CE with license for 1 year for 1 node.

Did you set a host name in your Tyk.conf?
[Tushar] tyk-gateway/tyk,conf
“hostname”: “127.0.0.1”,
“enable_custom_domains”: true,
“enable_jsvm”: true

you can see that in the logs which are usually in /var/log/upstart
[Tushar] no log files found there. There are other log files in the same directory sibling to upstart.
tail from syslog.log

Aug 9 20:53:38 tushar systemd[1]: Started Tyk API Dashboard.
Aug 9 20:53:38 tushar tyk-analytics[21393]: time=“Aug 9 20:53:38” level=info msg=“Using /opt/tyk-dashboard/tyk_analytics.conf for configuration”
Aug 9 20:53:38 tushar tyk-analytics[21393]: time=“Aug 9 20:53:38” level=info msg=“Creating new Redis connection pool”
Aug 9 20:53:38 tushar tyk-analytics[21393]: message repeated 3 times: [ time=“Aug 9 20:53:38” level=info msg=“Creating new Redis connection pool”]
Aug 9 20:53:38 tushar tyk-analytics[21393]: time=“Aug 9 20:53:38” level=info msg=“Adding available nodes…”
Aug 9 20:53:38 tushar tyk-analytics[21393]: time=“Aug 9 20:53:38” level=info msg=“Tyk Analytics Dashboard 1.2.0.0”
Aug 9 20:53:38 tushar tyk-analytics[21393]: time=“Aug 9 20:53:38” level=info msg=“Copyright Martin Buhr 2016”
Aug 9 20:53:38 tushar tyk-analytics[21393]: time=“Aug 9 20:53:38” level=info msg=“https://www.tyk.io
Aug 9 20:53:38 tushar tyk-analytics[21393]: time=“Aug 9 20:53:38” level=info msg=“Listening on port: 3000”
Aug 9 20:53:38 tushar tyk-analytics[21393]: time=“Aug 9 20:53:38” level=info msg=“Loading routes…”
Aug 9 20:53:38 tushar tyk-analytics[21393]: time=“Aug 9 20:53:38” level=info msg=“Registering nodes…”
Aug 9 20:53:38 tushar tyk-analytics[21393]: time=“Aug 9 20:53:38” level=info msg=“Creating new Redis connection pool”
Aug 9 20:53:38 tushar tyk-analytics[21393]: time=“Aug 9 20:53:38” level=info msg=“Adding available nodes…”
Aug 9 20:53:38 tushar tyk-analytics[21393]: time=“Aug 9 20:53:38” level=info msg=“Socket server started”
Aug 9 20:53:38 tushar tyk-analytics[21393]: time=“Aug 9 20:53:38” level=info msg=“–> Standard listener (http) for UI notifications”
Aug 9 20:53:38 tushar tyk-analytics[21393]: time=“Aug 9 20:53:38” level=info msg=“–> Standard listener (http) for dashboard and API”
Aug 9 20:56:10 tushar systemd[1]: Started Tyk API Gateway.
Aug 9 20:56:10 tushar tyk[21452]: time=“Aug 9 20:56:10” level=info msg=“Hostname set: 127.0.0.1”
Aug 9 20:56:10 tushar tyk[21452]: time=“Aug 9 20:56:10” level=warning msg=“Host checker data is no longer purged by Tyk Gateway, please use Tyk-Pump.”
Aug 9 20:56:10 tushar tyk[21452]: time=“Aug 9 20:56:10” level=info msg=“Connection dropped, connecting…”
Aug 9 20:56:10 tushar tyk[21452]: time=“Aug 9 20:56:10” level=warning msg=“Cache purging is no longer part of Tyk Gateway, please use Tyk-Pump.”
Aug 9 20:56:10 tushar tyk[21452]: time=“Aug 9 20:56:10” level=info msg=“Starting Poller”
Aug 9 20:56:10 tushar tyk[21452]: time=“Aug 9 20:56:10” level=info msg=“Setting up analytics normaliser”
Aug 9 20:56:10 tushar tyk[21452]: time=“Aug 9 20:56:10” level=info msg=“Setting up Server”
Aug 9 20:56:10 tushar tyk[21452]: time=“Aug 9 20:56:10” level=info msg=“–> Standard listener (http)”
Aug 9 20:56:10 tushar tyk[21452]: time=“Aug 9 20:56:10” level=info msg=“Registering node.”
Aug 9 20:56:10 tushar tyk[21452]: time=“Aug 9 20:56:10” level=info msg=“Node registered” id=f95c770e-6b49-463f-6478-a72ebdac9c7b
Aug 9 20:56:10 tushar tyk[21452]: time=“Aug 9 20:56:10” level=info msg=“Starting heartbeat.”
Aug 9 20:56:10 tushar tyk[21452]: time=“Aug 9 20:56:10” level=info msg=“Detected 1 APIs”
Aug 9 20:56:10 tushar tyk[21452]: time=“Aug 9 20:56:10” level=info msg=“Loading API configurations.”
Aug 9 20:56:10 tushar tyk[21452]: time=“Aug 9 20:56:10” level=info msg=“–> Loading API: Users”
Aug 9 20:56:10 tushar tyk[21452]: time=“Aug 9 20:56:10” level=info msg=“----> Custom Domain: 127.0.0.1”
Aug 9 20:56:10 tushar tyk[21452]: time=“Aug 9 20:56:10” level=info msg=“----> Tracking: 127.0.0.1”
Aug 9 20:56:10 tushar tyk[21452]: time=“Aug 9 20:56:10” level=info msg=“----> Checking security policy: Open”
Aug 9 20:56:10 tushar tyk[21452]: time=“Aug 9 20:56:10” level=info msg=“Loading uptime tests…”
Aug 9 20:56:10 tushar tyk[21452]: time=“Aug 9 20:56:10” level=info msg=“Initialised API Definitions”
Aug 9 20:56:10 tushar tyk[21452]: time=“Aug 9 20:56:10” level=info msg=“Gateway started (v2.2.0.1)”
Aug 9 20:56:10 tushar tyk[21452]: time=“Aug 9 20:56:10” level=info msg=“–> Listening on port: 8080”

tyk-gateway/tyk,conf

{
“listen_port”: 8080,
“node_secret”: “352d20ee67be67f6340b4c0605b044b7”,
“secret”: “352d20ee67be67f6340b4c0605b044b7”,
“template_path”: “/opt/tyk-gateway/templates”,
“tyk_js_path”: “/opt/tyk-gateway/js/tyk.js”,
“use_db_app_configs”: true,
“db_app_conf_options”: {
“connection_string”: “http://127.0.0.1:3000”,
“node_is_segmented”: false,
“tags”: []
},
“app_path”: “/opt/tyk-gateway/apps”,
“middleware_path”: “/opt/tyk-gateway/middleware”,
“storage”: {
“type”: “redis”,
“host”: “127.0.0.1”,
“port”: 6379,
“username”: “”,
“password”: “”,
“database”: 0,
“optimisation_max_idle”: 2000,
“optimisation_max_active”: 4000
},
“enable_analytics”: true,
“analytics_config”: {
“type”: “mongo”,
“csv_dir”: “/tmp”,
“mongo_url”: “”,
“mongo_db_name”: “”,
“mongo_collection”: “”,
“purge_delay”: 100,
“ignored_ips”: [],
“enable_detailed_recording”: true,
“enable_geo_ip”: false,
“geo_ip_db_path”: “”,
“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”: “service”,
“policy_connection_string”: “http://127.0.0.1:3000”,
“policy_record_name”: “tyk_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
},
“http_server_options”: {
“enable_websockets”: true
},
“uptime_tests”: {
“disable”: false,
“config”: {
“enable_uptime_analytics”: true,
“failure_trigger_sample_size”: 3,
“time_wait”: 300,
“checker_pool_size”: 50
}
},
“hostname”: “127.0.0.1”,
“enable_custom_domains”: true,
“enable_jsvm”: true
}

tried all. Listen path is not getting mapped to the target path.
Dashboard, gateway are on the same machine. Can this be a problem ?

Could be, can you post your API spec?

{
“id”: “57a7d9d4df7c903948000002”,
“name”: “Users”,
“slug”: “get-user”,
“api_id”: “c19970ae9f0341c97e0d06b47bf4d8b9”,
“org_id”: “57a7d891df7c903948000001”,
“use_keyless”: true,
“use_oauth2”: false,
“use_openid”: false,
“openid_options”: {
“providers”: [],
“segregate_by_client”: false
},
“oauth_meta”: {
“allowed_access_types”: [],
“allowed_authorize_types”: [],
“auth_login_redirect”: “”
},
“auth”: {
“use_param”: false,
“param_name”: “”,
“use_cookie”: false,
“cookie_name”: “”,
“auth_header_name”: “”
},
“use_basic_auth”: false,
“enable_jwt”: false,
“jwt_signing_method”: “”,
“jwt_source”: “”,
“jwt_identity_base_field”: “”,
“jwt_client_base_field”: “”,
“jwt_policy_field_name”: “”,
“notifications”: {
“shared_secret”: “”,
“oauth_on_keychange_url”: “”
},
“enable_signature_checking”: false,
“hmac_allowed_clock_skew”: -1,
“definition”: {
“location”: “header”,
“key”: “x-api-version”
},
“version_data”: {
“not_versioned”: true,
“versions”: {
“Default”: {
“name”: “Default”,
“expires”: “”,
“paths”: {
“ignored”: [],
“white_list”: [],
“black_list”: []
},
“use_extended_paths”: true,
“extended_paths”: {
“ignored”: [],
“white_list”: [
{
“path”: “users/{id}”,
“method_actions”: {
“GET”: {
“action”: “no_action”,
“code”: 200,
“data”: “”,
“headers”: {}
}
}
}
],
“black_list”: [],
“cache”: [],
“transform”: [],
“transform_response”: [],
“transform_headers”: [],
“transform_response_headers”: [],
“hard_timeouts”: [],
“circuit_breakers”: [],
“url_rewrites”: [],
“virtual”: [],
“size_limits”: [],
“method_transforms”: []
},
“global_headers”: {
“Content-Type”: “application/json”
},
“global_headers_remove”: [],
“global_size_limit”: 0,
“override_target”: “”
}
}
},
“uptime_tests”: {
“check_list”: [],
“config”: {
“expire_utime_after”: 0,
“service_discovery”: {
“use_discovery_service”: false,
“query_endpoint”: “”,
“use_nested_query”: false,
“parent_data_path”: “”,
“data_path”: “”,
“port_data_path”: “”,
“target_path”: “”,
“use_target_list”: false,
“cache_timeout”: 60,
“endpoint_returns_list”: false
},
“recheck_wait”: 0
}
},
“proxy”: {
“preserve_host_header”: false,
“listen_path”: “/users/*”,
“target_url”: “http://127.0.0.1:8888/user-service”,
“strip_listen_path”: false,
“enable_load_balancing”: false,
“target_list”: [],
“check_host_against_uptime_tests”: false,
“service_discovery”: {
“use_discovery_service”: false,
“query_endpoint”: “”,
“use_nested_query”: false,
“parent_data_path”: “”,
“data_path”: “hostname”,
“port_data_path”: “port”,
“target_path”: “/api-slug”,
“use_target_list”: false,
“cache_timeout”: 60,
“endpoint_returns_list”: false
}
},
“custom_middleware”: {
“pre”: [],
“post”: [],
“response”: []
},
“cache_options”: {
“cache_timeout”: 60,
“enable_cache”: false,
“cache_all_safe_requests”: false,
“cache_response_codes”: [],
“enable_upstream_cache_control”: false
},
“session_lifetime”: 0,
“active”: true,
“auth_provider”: {
“name”: “”,
“storage_engine”: “”,
“meta”: {}
},
“session_provider”: {
“name”: “”,
“storage_engine”: “”,
“meta”: null
},
“event_handlers”: {
“events”: {}
},
“enable_batch_request_support”: false,
“enable_ip_whitelisting”: false,
“allowed_ips”: [],
“dont_set_quota_on_create”: false,
“expire_analytics_after”: 0,
“response_processors”: [],
“CORS”: {
“enable”: false,
“allowed_origins”: [],
“allowed_methods”: [
“GET”
],
“allowed_headers”: [],
“exposed_headers”: [],
“allow_credentials”: false,
“max_age”: 24,
“options_passthrough”: false,
“debug”: false
},
“domain”: “127.0.0.1”,
“do_not_track”: false,
“tags”: [],
“enable_context_vars”: false
}

Remove the host name from the tyk.conf, that could be causing problems because they are the same.

Also, maybe use an actual host name instead of an IP?

Finally, after 2 days , it’s resolved and working. Changes -

  1. “hostname”: from “127.0.0.1” to “”,
  2. custom domain - from 127.0.0.1:8080 to localhost
  3. Listen path from /users/ to /users/{id}
  4. target URL from http://127.0.0.1:8888/user-service /to http://localhost:8888/user-service

I feel good now.
Thanks Martin, Matiasb

How do I mark this thread as resolved ? Please close this thread if you have higher privilege.

1 Like