Portal and subdomain


#1

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


#2

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.


#3

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.


#4

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


#5

Thanks! I’ll do that.


#6

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


#7

Did you restart the dashboard?


#8

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


#9

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

https://tyk.io/v1.9/configuration/dashboard-config/#enable-host-names:8f1ac6c580c2f6cd2c8954a33f3ca4d6

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.


#10

{
“listen_port”: 3000,
“tyk_api_config”: {
“Host”: “http://apis.domain.info”,
“Port”: “8080”,
“Secret”: “*********”
},
“mongo_url”: “mongodb://10.1.0.11/tyk_analytics”,
“page_size”: 10,
“admin_secret”: “*********”,
“redis_port”: 6379,
“redis_host”: “10.1.0.14”,
“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”
}


#11

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).


#12

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:

https://github.com/lonelycode/tyk-host-daemon/blob/master/templates/portal.conf

Cheers,
Martin