Portal and subdomain

I have tyk-gateway configured to run on subdomain like services.domain.com and tyk-dashboard running on mgm.services.domain.com. I can’t figure how to run portal on subdomain services.domain.com since it’s not a valid CNAME.

Could you help me please?

Thanks in advance

You want the portal to run on the same subdomain as the gateway? That’s a tough one, you need to proxy the portal via the gateway. Take a look at the docker setup guide and scripts, they do that.

A better supported version would be to have apis.domain.com - your gateway, developers.domain.com - your portal mgmt.domain.com - your dashboard.

Hi Martins, thanks for the quick reply.
I want exactly that (apis.domain.com, developers.domain.com and mgm.domain.com).

The problem is that when I try to set “developers.domain.com” on “Set your portal domain” it returns an error saying that’s an invalid CNAME. I’m completely lost here on portal configuration.

Ah, Tyk validates the CNAME really strictly, to use a non-standard one, you either need to modify the CNAME attribute in your mongoDB directly, or force it in the tyk_analytics.conf

1 Like

Thanks! I’ll do that.

Well, I did that. I defined developers.apis.domain.com directly on MongoDB collection but accessing this links returns “Not Found”. Any ideas?

Did you restart the dashboard?

yes. I meant accessing on browser to developers.apis.domain.com/portal

Can you share your tyk_analytics.conf file? You need to have the various domain options enabled:


Finally, the gateway and dashboard/portal run on different ports, so if you are on a single host with all components you’re going to need a different approach.

“listen_port”: 3000,
“tyk_api_config”: {
“Host”: “http://apis.domain.info”,
“Port”: “8080”,
“Secret”: “"
“mongo_url”: “mongodb://”,
“page_size”: 10,
“admin_secret”: "
“redis_port”: 6379,
“redis_host”: “”,
“redis_password”: “”,
“force_api_defaults”: false,
“notify_on_change”: true,
“license_owner”: “InfoPortugal S.A.”,
“hash_keys”: false,
“email_backend”: {},
“hide_listen_path”: false,
“use_sentry”: false,
“sentry_code”: “”,
“sentry_js_code”: “”,
“show_org_id”: true,
“enable_duplicate_slugs”: true,
“host_config” : {
“override_hostname”: “apis.domain.info”,
“disable_org_slug_prefix”: true,
“enable_host_names”: true,
“hostname”: “mgm.apis.domain.info”,
“portal_domains”: {},
“portal_root_path”: “/portal”
“http_server_options”: {
“use_ssl”: false,
“certificates”: [
“ui”: {
“login_page”: {},
“nav” : {},
“uptime”: {},
“portal”: {},
“designer”: {}
“home_dir”: “/opt/tyk-dashboard”

I am on a single host with dashboard and gateway components. I use nginx in order to proxy requests for the different components. apis.domain.info points to localhost:8080 (gateway) and mgm.apis.domain.info points to localhost:3000 (portal).

Ok, so NGinX is handling the rewrites for you, but Tyk Dash will be binding to the domain:port, which means it will always error because that’s not what NginX is sending as a hosts header, you could modify the hosts header on the fly (not sure it would work though).

Because NginX is sitting in front of Tyk, you need to disable domain handling in Tyk dashboard and do it all exclusively in nginx, the same way the host manager does it.

Basically, disable host names in the dashboard, and add a portal rewrite to NginX. This is the template the host manager uses, if you strip out all the template vars you should get what you need for the portal rewrites: