Test Api urls ,return 404 not found(Solved)

I have installed the tyk by following the guide: with-tyk-on-premise installation in Centos 7, can login Tyk-dashboard successful.

Create new Api for test by following the Tutorials url.

The api url is: http://10.4.2.98:8080/testapi3/test, test rusult as follow:
[root@localhost ~]# curl -X GET -H ‘Authorization: 5b6a9a6ae138230df675f3c01ed167a8c7674e13aec11cd2dd850233’ -i ‘http://10.4.2.98:8080/testapi3/test
HTTP/1.1 404 Not Found
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Date: Fri, 10 Aug 2018 06:09:41 GMT
Content-Length: 19

404 page not found

How can i solve this error ?

The tyk.conf content as follow:
{
“listen_port”: 8080,
“secret”: “352d20ee67be67f6340b4c0605b044b7”,
“template_path”: “/opt/tyk-gateway/templates”,
“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”: “”,
“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”: false,
“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”: 2,
“time_wait”: 10,
“checker_pool_size”: 50
}
},
“http_server_options”: {
“enable_websockets”: true
},
“hostname”: “”,
“enable_custom_domains”: true,
“enable_jsvm”: true,
“oauth_redirect_uri_separator”: “;”,
“coprocess_options”: {
“enable_coprocess”: false,
“coprocess_grpc_server”: “”
},
“pid_file_location”: “./tyk-gateway.pid”,
“allow_insecure_configs”: true,
“public_key_path”: “”,
“close_idle_connections”: false,
“allow_remote_config”: false,
“enable_bundle_downloader”: true,
“bundle_base_url”: “”,
“global_session_lifetime”: 100,
“force_global_session_lifetime”: false,
“use_redis_log”:true,
“max_idle_connections_per_host”: 500
}

tyk_analytics.conf content as follow:
{
“listen_port”: 3000,
“tyk_api_config”: {
“Host”: “http://localhost”,
“Port”: “8080”,
“Secret”: “352d20ee67be67f6340b4c0605b044b7”
},
“mongo_url”: “mongodb://127.0.0.1/tyk_analytics”,
“mongo_use_ssl”: false,
“mongo_ssl_insecure_skip_verify”: false,
“page_size”: 10,
“admin_secret”: “12345”,
“shared_node_secret”: “352d20ee67be67f6340b4c0605b044b7”,
“redis_port”: 6379,
“redis_host”: “localhost”,
“redis_password”: “”,
“enable_cluster”: false,
“redis_use_ssl”: false,
“redis_ssl_insecure_skip_verify”: false,
“force_api_defaults”: false,
“notify_on_change”: true,
“license_key”: “eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhbGxvd2VkX25vZGVzIjoiY2VhZDllNjktMWQ4Ni00N2FhLTY4YzEtMjRlNmNkYjY5MTQ2IiwiZXhwIjoxNTY1MDYxNzE3LCJvd25lciI6IjViNjQxNzMxNDVmOTJlMDcxNDcyZGMyZSJ9.1M7UJNJuJxCtzKve8X2wVvqtTqk8NIgbdY6vX6Mi3YXAiEG8wit72YrVAeBdYWvCL5p1yWn06s08yKMUuZ1ab8Q7qHBjp907qdG1beAxsHFBhYmiD1qAMxkarSkGslV7NV9lhQU-ztv0seDp5DTnFYEHx-bEpm9qd-Qsn84HldlCOVDi7Fi9SKbI4w54KJX-mYBMwc5DdAX6PaUC2RyHQuMe8Ra-2SG6mrNNt8W61j6B8E3G_bkYCEIs_NiPKE0oM9fvLsmbxpKEPzrC5GnnylCaF9xXnQrGKEAC2eGozvPHQaLeFXOZDUTh1ynNtOKjXrhKK199PO9dRi1jaiRlqQ”,
“redis_database”: 0,
“redis_hosts”: null,
“hash_keys”: true,
“email_backend”: {
“enable_email_notifications”: false,
“code”: “”,
“settings”: null,
“default_from_email”: “”,
“default_from_name”: “”,
“dashboard_hostname”: “”
},
“hide_listen_path”: false,
“sentry_code”: “”,
“sentry_js_code”: “”,
“use_sentry”: false,
“enable_master_keys”: false,
“enable_duplicate_slugs”: true,
“show_org_id”: true,
“host_config”: {
“enable_host_names”: true,
“disable_org_slug_prefix”: true,
“hostname”: “10.4.2.98”,
“override_hostname”: “localhost.localdomain”,
“portal_domains”: {},
“portal_root_path”: “/portal”,
“generate_secure_paths”: false,
“secure_cookies”: false,
“use_strict_hostmatch”: false
},
“http_server_options”: {
“use_ssl”: false,
“certificates”: [
{
“domain_name”: “”,
“cert_file”: “”,
“key_file”: “”
}
],
“min_version”: 0
},
“security”: {
“allow_admin_reset_password”: false,
“login_failure_username_limit”: 0,
“login_failure_ip_limit”: 0,
“login_failure_expiration”: 0,
“audit_log_path”: “”
},
“ui”: {
“languages”: {
“Chinese”: “cn”,
“English”: “en”,
“French”: “fr”,
“Korean”: “ko”
},
“hide_help”: false,
“default_lang”: “en”,
“login_page”: {},
“nav”: {},
“uptime”: {},
“portal_section”: null,
“designer”: {},
“dont_show_admin_sockets”: false,
“dont_allow_license_management”: false,
“dont_allow_license_management_view”: false,
“cloud”: false
},
“home_dir”: “/opt/tyk-dashboard”,
“identity_broker”: {
“enabled”: false,
“host”: {
“connection_string”: “http://localhost:3010”,
“secret”: “934893845123491238192381486djfhr87234827348”
}
},
“tagging_options”: {
“tag_all_apis_by_org”: false
},
“use_sharded_analytics”: false,
“enable_aggregate_lookups”: true,
“enable_analytics_cache”: false,
“aggregate_lookup_cutoff”: “01/07/2016”,
“maintenance_mode”: false,
“allow_explicit_policy_id”: false,
“private_key_path”: “”,
“node_schema_path”: “”,
“oauth_redirect_uri_separator”: “;”,
“statsd_connection_string”: “”,
“statsd_prefix”: “”,
“disable_parallel_sessions”: false,
“dashboard_session_lifetime”: 0,
“alternative_dashboard_url”: “”,
“sso_permission_defaults”: null,
“sso_default_group_id”: “”,
“sso_custom_login_url”: “”,
“sso_custom_portal_login_url”: “”,
“notifications_listen_port”: 5000,
“portal_session_lifetime”: 0,
“enable_delete_key_by_hash”: false
}

Is your gateway service running?

If you run sudo netstat -tlnp can you see the gateway process listening on port 8080?

If the Gateway is up is it definitely available on that address can you call the /health endpoint and get a response?

The gateway service have running, listen port as:
tcp6 0 0 :::8080 :::* LISTEN

you are on localhost so need to call 127.0.0.1:8080

call 127.0.0.1:8080 also appear 404 not found .

curl -X GET -H ‘Authorization: 5b6a9a6ae138230df675f3c042bf9c1ada554a5489143c618580764e’ -i ‘http://127.0.0.1:8080/testapi4/
HTTP/1.1 404 Not Found
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Date: Sat, 11 Aug 2018 03:40:16 GMT
Content-Length: 19

404 page not found

I have check the Mongod.log file found that:
2018-08-11T11:26:35.456+0800 I CONTROL [main] ***** SERVER RESTARTED *****
2018-08-11T11:26:41.310+0800 I CONTROL [initandlisten] MongoDB starting : pid=1297 port=27017 dbpath=/var/lib/mongo 64-bit host=localhost.localdomain
2018-08-11T11:26:41.310+0800 I CONTROL [initandlisten] db version v4.0.1
2018-08-11T11:26:41.310+0800 I CONTROL [initandlisten] git version: 54f1582fc6eb01de4d4c42f26fc133e623f065fb
2018-08-11T11:26:41.310+0800 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
2018-08-11T11:26:41.310+0800 I CONTROL [initandlisten] allocator: tcmalloc
2018-08-11T11:26:41.310+0800 I CONTROL [initandlisten] modules: none
2018-08-11T11:26:41.310+0800 I CONTROL [initandlisten] build environment:
2018-08-11T11:26:41.310+0800 I CONTROL [initandlisten] distmod: rhel70
2018-08-11T11:26:41.310+0800 I CONTROL [initandlisten] distarch: x86_64
2018-08-11T11:26:41.310+0800 I CONTROL [initandlisten] target_arch: x86_64
2018-08-11T11:26:41.310+0800 I CONTROL [initandlisten] options: { config: “/etc/mongod.conf”, net: { bindIp: “127.0.0.1”, port: 27017 }, processManagement: { fork: true, pidFilePath: “/var/run/mongodb/mongod.pid”, timeZoneInfo: “/usr/share/zoneinfo” }, storage: { dbPath: “/var/lib/mongo”, journal: { enabled: true } }, systemLog: { destination: “file”, logAppend: true, path: “/var/log/mongodb/mongod.log” } }
2018-08-11T11:26:41.364+0800 I STORAGE [initandlisten] Detected data files in /var/lib/mongo created by the ‘wiredTiger’ storage engine, so setting the active storage engine to ‘wiredTiger’.
2018-08-11T11:26:41.364+0800 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1463M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress),
2018-08-11T11:26:43.614+0800 I STORAGE [initandlisten] WiredTiger message [1533958003:614419][1297:0x7f639c381b00], txn-recover: Main recovery loop: starting at 10/62336
2018-08-11T11:26:43.755+0800 I STORAGE [initandlisten] WiredTiger message [1533958003:755707][1297:0x7f639c381b00], txn-recover: Recovering log 10 through 11
2018-08-11T11:26:43.864+0800 I STORAGE [initandlisten] WiredTiger message [1533958003:864795][1297:0x7f639c381b00], txn-recover: Recovering log 11 through 11
2018-08-11T11:26:43.953+0800 I STORAGE [initandlisten] WiredTiger message [1533958003:953344][1297:0x7f639c381b00], txn-recover: Set global recovery timestamp: 0
2018-08-11T11:26:44.005+0800 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2018-08-11T11:26:44.605+0800 I CONTROL [initandlisten]
2018-08-11T11:26:44.605+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-08-11T11:26:44.605+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2018-08-11T11:26:44.605+0800 I CONTROL [initandlisten]
2018-08-11T11:26:44.605+0800 I CONTROL [initandlisten]
2018-08-11T11:26:44.605+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is ‘always’.
2018-08-11T11:26:44.605+0800 I CONTROL [initandlisten] ** We suggest setting it to ‘never’
2018-08-11T11:26:44.605+0800 I CONTROL [initandlisten]
2018-08-11T11:26:44.605+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is ‘always’.
2018-08-11T11:26:44.605+0800 I CONTROL [initandlisten] ** We suggest setting it to ‘never’
2018-08-11T11:26:44.605+0800 I CONTROL [initandlisten]
2018-08-11T11:26:45.063+0800 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory ‘/var/lib/mongo/diagnostic.data’
2018-08-11T11:26:45.109+0800 I NETWORK [initandlisten] waiting for connections on port 27017
2018-08-11T11:27:23.418+0800 I NETWORK [listener] connection accepted from 127.0.0.1:53636 #1 (1 connection now open)
2018-08-11T11:27:32.014+0800 I NETWORK [listener] connection accepted from 127.0.0.1:53662 #2 (2 connections now open)
2018-08-11T11:27:32.019+0800 I NETWORK [listener] connection accepted from 127.0.0.1:53664 #3 (3 connections now open)
2018-08-11T11:27:32.021+0800 I NETWORK [listener] connection accepted from 127.0.0.1:53666 #4 (4 connections now open)
2018-08-11T11:31:04.296+0800 I NETWORK [listener] connection accepted from 127.0.0.1:53766 #5 (5 connections now open)
2018-08-11T11:31:04.296+0800 I NETWORK [listener] connection accepted from 127.0.0.1:53768 #6 (6 connections now open)
2018-08-11T11:31:09.411+0800 I COMMAND [conn6] command tyk_analytics.tyk_apis command: find { find: “tyk_apis”, filter: { org_id: “5b6a9a6ae138230df675f3c0” }, sort: { _id: -1 }, skip: 0, $readPreference: { mode: “secondaryPreferred” }, $db: “tyk_analytics” } planSummary: IXSCAN { _id: 1 } keysExamined:3 docsExamined:3 cursorExhausted:1 numYields:1 nreturned:3 reslen:11925 locks:{ Global: { acquireCount: { r: 2 } }, Database: { acquireCount: { r: 2 } }, Collection: { acquireCount: { r: 2 } } } protocol:op_query 148ms
2018-08-11T12:28:32.595+0800 I NETWORK [listener] connection accepted from 127.0.0.1:53946 #7 (7 connections now open)
2018-08-11T12:28:32.595+0800 I NETWORK [listener] connection accepted from 127.0.0.1:53948 #8 (8 connections now open)
2018-08-11T12:28:32.595+0800 I NETWORK [listener] connection accepted from 127.0.0.1:53950 #9 (9 connections now open)

have appear the warnning message:
WARNING: Access control is not enabled for the database.
2018-08-11T11:26:44.605+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.

This configture have affect the test Api ?

how can I modify the Access contorl can Read and write data for the database ?

I have solved the error. when Create api, can’t input the Customer Domain. test as :curl -X GET -H ‘Authorization: 5b6a9a6ae138230df675f3c0d1576596ab5e47cdb3be3fe1df0003ef’ -i ‘http://10.4.2.98:8080/testapi1/’ or curl -X GET -H ‘Authorization: 5b6a9a6ae138230df675f3c0d1576596ab5e47cdb3be3fe1df0003ef’ -i ‘http://127.0.0.1:8080/testapi1/’ will return status code 200.

hello Josh. Can you help me to reply a question? the question is that:
how to get the sending of the automatic emails to work? Didn’t find much documentation about it on tyk site.

I have setup the Developer portal, after the developer user request a API key in API Catalogue. In portal Management of admin user can approve the request key. I hope that after the admin have approve key, Developer user can receive email.
In the Setting of port Management ,have setting API Key approval email ,select Enable custom approval email .
After approve the key, check the log file is that: Email notifications disabled, skipping Send(), Can you tell me how to setup automatic sending Emai to work?(modify tyk_analytics.conf and others)

Thank you for you help.