TYK Portal

Imported Google Group message. Original thread at: Redirecting to Google Groups Import Date: 2016-01-19 21:11:47 +0000.
Sender:Jayadatta Vallabhaneni.
Date:Tuesday, 5 May 2015 18:27:20 UTC+1.

Hi Martin,

I am trying to deploy portal on a docker. Could you please let me know if we need to add the sub-domain configuration on the docker host or the in the docker image itself. I am able to bring up the docker, but when i try to login to the portal it is throwing 404 error.

Thanks,
Jayadatta

Imported Google Group message.
Sender:Martin Buhr.
Date:Tuesday, 5 May 2015 18:56:09 UTC+1.

Hi Jay,

That depends on which docker build you are using :slight_smile: But you should just need to define it on the host to point at the docker container (we did a little blog post on it here)

We actually have three docker images on docker hub:

  1. tykio/tyk-gateway - this is just the gateway
  2. tykio/tyk-dashboard - this is the dashboard + portal
  3. tykio/tyk-host-manager - this is the host manager, as of 1.6 it is decoupled from the gateway, it is no longer needed for hot reloads of Tyk but can manage NginX for you, this is the easiest way to get domains managed

The portal is part of the dashboard, so the domain configuration needs to point at the dashboard, if you look at the sample configs provided for NginX you can see a good idea of how the portal routes work, it’s all done by OrgID, strictly speaking you can get at the portal (it won’t render properly) by going to http://xx.xx.xx.xx:3000/{OrgID}/portal

Here’s the nginx template for the host manager in a docker container:

server {
{{if .OwnerSlug}}
server_name {{.OwnerSlug}}.DOMAINALIAS;
{{else}}
server_name {{.Id.Hex}}.DOMAINALIAS;
{{end}}

    gzip              on;
    gzip_buffers      16 8k;
    gzip_comp_level   4;
    gzip_http_version 1.1;
    gzip_min_length   1280;
    gzip_types        text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon image/bmp;
    gzip_vary         on;


    # The Go application server
    location /portal/ {
        rewrite /portal/(.*) /{{.Id.Hex}}/portal/$1 break;


        proxy_pass_header Server;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Scheme $scheme;
        proxy_pass http://dashboard;
    }
    location /portal-assets/ {
        proxy_pass_header Server;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Scheme $scheme;
        proxy_pass http://dashboard;
    }
    location /api/public {
        proxy_pass_header Server;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Scheme $scheme;
        proxy_pass http://dashboard;
    }

}

As you can see, we rewrite quite a few URL’s, but essentially everything points at the dashboard.

Have you tried the quickstart script? It will get everything set up for you quite quickly on a local machine to test, if you investigate the nginx configurations that are generated by the host manager you can see it all in action.

If you don’t mind NginX managing the API domains, then I would further suggest using our host-manager container as it’s all set up already with nginx and can be linked with the others very easily.

I hope that helps :slight_smile:

Thanks,
Martin

  • show quoted text -

Imported Google Group message.
Sender:Jayadatta Vallabhaneni.
Date:Tuesday, 5 May 2015 19:24:15 UTC+1.

Thank you Martin for the detail write-up. I am trying to deploy this in Amazon Beanstalk. Will go through the blog and will update you.

Regards,
Jayadatta

  • show quoted text -

Imported Google Group message.
Sender:Martin Buhr.
Date:Tuesday, 5 May 2015 19:36:48 UTC+1.

Ah I see, hmmm, haven;t tried beanstalk yet - but ultimately, if you know the subdomains you are going to set up already and don;t need them managed, you can just point the domains at the docker container that has the dashboard.

Basically:

  1. Gateway: needs to see Mongo & Redis (also needs an open port for requests, e.g. 5000)
  2. Dashboard & Portal: Needs to see Gateway + Mongo + Redis (needs an open port, e.g. 3000)

You don’t need the host manager, if you are deploying a fixed set of API’s or don’t mind managing domains maually

Otherwise:
3. Host manager: Needs to see: Mongo, Redis (and gateway, if legacy setup - pre-1.6) and be on the same host as nginx, you will also need to remove and symlink /etc/nginx/sites-enabled (or /etc/nginx/conf.d depending on the base system) to the nginx_confs folder in the tyk-host-manager directory for the configurations to be built correctly.

Note: The host manager is shipped with the dashboard tarball, but doesn’t need to be with it, it’s just a convenient package. In our host manager container, we actually download the dashbaord tarball and unzip it, then ignore the dashboard and just use the host manager folder.

Good luck, and let me know if you get any further :slight_smile:

Cheers,
Martin

  • show quoted text -

Imported Google Group message.
Sender:Jayadatta Vallabhaneni.
Date:Wednesday, 6 May 2015 07:39:23 UTC+1.

Thanks Martin.

I am finally able to run the portal on beanstalk. All the three dockers (Gateway, Dashboard and Portal) are up and running in aws.

I have observed a small issue with the portal. If the apiid+ sub domain length exceeds the default server_names_hash_bucket_size size (32 chars in my case), portal fails to start. To overcome this, i have made the following changes to my docker file.

commented/removed: COPY _upstream.conf /opt/tyk-dashboard/host-manager/nginx_confs/
Added: COPY nginx.conf /etc/nginx/nginx.conf (modified nginx config file. It has all the _upstream.conf commands + server_names_hash_bucket_size value embedded in it.)

Attached is my docker and nginx config file. Please let me know if you see any issues in running the portal with the updated configuration files.

~Jay

  • show quoted text -

Imported Google Group message.
Sender:Martin Buhr.
Date:Wednesday, 6 May 2015 09:08:02 UTC+1.

Hi Jay,

Thanks for that - we’ve integrated into into our Docker build :slight_smile: with one small difference, we’ve put the variable into the _upstream.conf file, this way end-users can use their own nginx.conf file and so long as they include the *.conf files in the conf.d/ diretory it will be configured corretly for Tyk, this means the tyk secific configuration is as isolated as possible.

Let me know how it goes with the Portal, it’s very configurable, so there’s lots of options.

Cheers,
Martin

  • show quoted text -

Imported Google Group message.
Sender:Jayadatta Vallabhaneni.
Date:Thursday, 7 May 2015 21:45:37 UTC+1.

Thanks Martin. Portal is working fine now.

Regards,
~Jay

  • show quoted text -