No Nodes Running - Dashboard [SOLVED]

Have managed to get everything up and running perfectly except that the dash board cannot find any nodes that are running.

Things I have checked:

Redis is running
Mongo Db is running
secrets have been set in both tyk.conf and tyk_analytics.conf
APIs have been created
port 5000 (tyk port) is open and accepting connections
License is active and shows Total Available as 1 and Total Remaining as 1

Other than this, I am not sure what else to look at.

The only other information is that all requests currently wind up at the dashboard (there is a dedicated domain served by NGINX with the upstream of 5000 but this just winds up at the dashboard for some reason. Tyk is NOT serving or managing hosts.

Just a quick update.

Found the note about setting up the “Portal Domain Name”.

I am not sure if this is a bug but it changes the API urls too. The case that we have is

gateway.mydomain.com

This is the link that ALL our APIs live on. so you would access

 gateway.mydomain.com/api/v/info
 gateway.mydomain.com/otherapi/v1/info

When users hit this domain on NGINX via port 80, NGINX proxy_passes the request to an upstream server called tyke which is running on 5000 which then serves the request.

dashboard.mydomain.com
This is where admin access the dashboard. This is also served by NGINX with an upstream to :3000

portal.mydomain.com
This is the “marketing url” that we will use for people who want to consume our APIs. This is the semantic equivalent of http://dashboard.mydomain.com/portal. NGINX rewrites the url via:

 location /{


       # rewrite ^/\$ /portal break;
        rewrite /(.*) /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;
    }

I have turned off tyk managing hosts as previously advised. Using this:

Results in the gateway subdomain changing as well which is undesired.

The current setup still results in an:

Homepage Not Found error

at a loss :frowning:

Short version: while the dash and gateway URLS will be ok, the portal needs a special rewrite rule, templates for which you can find in the dashboard/host-manager sub directory on your server.

Basically, because you are running via NGinX, you need to go back to pre-1.8 style of domain management, which involved managed NGinX templates using or host manager app (still bundled, still works):

https://tyk.io/docs/tyk-api-gateway-v1-9/host-manager/

In your case, since Tyk Dashboard is no longer binding to domains, the portal domain is now also no longer used, instead it uses the OrgID to target the correct portal (Tyk is multi-tenant).

Setting the CNAME via the dashboard will cause Tyk Dash to assume the domain is also being used for the gateway and all the published URLs in the dash will use the CNAME (they won’t be live though, because you aren’t domain binding, so it’s just incorrect)

We’ve already written all the templates for NGinX to make this kind of config work (lots of people still use the host manager) - in the Tyk Dashboard directory there is a host manager directory, in there are some templates for NGinX that show you how to manage rewrites for a non-domain bound install.

Alternatively, just use the host manager :slight_smile:

Hey Martin!

Thanks for that. For some reason (my love of inflicting self harm via code) I really want to maintain the transparency by running NGINX as a standalone.

I checked the tyk --help flag but it does not list how to grab the organisation IDs in v2. Maybe I am missing the place in the dashboard?

It think the amount of work you have done since is really great by the way. Not sure I understand why NGINX was bundled in with Tyk though but I am sure I will get the hang of it soon.

I will keep hammering away to get this working. Thank you for your dedication and responses to my noob questions.

Oh! Sorry, i still have no nodes running. I have checked the ports but dashboard is not seeing tyk. Is this to do with the host-manager?

So the domain thing has been solved:

For anyone wanting to do what I am.

You need to create three NGINX virtual hosts:

the portal file needs to look like this:

server {
 
    listen 80;
    server_name portal.thisiswhereyoucanaccessmyportal.com;
    rewrite_log on;
    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 / {
            rewrite /(.*) /[CHANGE THIS TO THE ORGANISATION ID YOU ARE USING]/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;
        }
}

If you need your ORGANISATIONID you can get that by clicking any user and copying their RPC credentials.

The portal should fire up given that you have set it up correctly.

Will post a solution for the “no nodes running” issue as soon as I have one.

Nada! Have no been able to get this working. The portal is fine now, the gateway just return “not found” for any combination of paths it is passed.

The nginx gateway.conf looks like

   location / {

       rewrite /(.*) /[API_SLUG]/$1 break; 404
      #rewrite /(.*) /[LISTENPATH]/$1 break; - 404
      #rewrite /(.*) /[API_ID]/$1 break; - 404

       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://tyk/;
      #proxy_pass http://httpbin.org;
  }

If I swop out the upstream for “httpbin.org” redirects with no 404 unless I add a path. If I push this to the upstream I just get a 404 which to me seems like TYK-GATEWAY does not have access to the API definitions which may be why I am getting that no nodes running error. NGINX is picking up the rewrites and throwing them the right way (logging rewrites at INFO level).

At a total loss. This is the last step (I hope :slight_smile: ) Any advice much appreciated.

You are rewriting the root to a fixed API slug, I’m not sure that’s what you want, the rewrite isn’t very flexible, try:

rewrite /(.*) /$1 break; 

I think this is what you had before for your gateway, what you want to achieve is that everything gets proxied to Tyk for processing, you need the listen path to reach Tyk.

You may be correct in assuming that Tyk doesn’t have an API to listen to, in which case it will always 404.

If there’s no nodes listed in the dashboard, I have a feeling Tyk isn’t bootstrapping and registering, so I’d suggest tailing the log files of the gateway (/var/log or /var/log/upstart).

You’ll need to solve that before your NGinX rewrite.

clears throat

Thanks for your patience Martin. This was totally a ID 10 T operator error.

PORT 5000 was for some reason being eaten by another process. I changed that and everything stabilised. Nodes are being picked up. For those who follow this path.

check you /var/log/tyk-gateway.stderr file

if you are getting something that looks like this:

'time="May 14 08:08:22" level=info msg="Setting up Server"
time="May 14 08:08:22" level=info msg="--> Standard listener (http)"
time="May 14 08:08:22" level=info msg="Registering node."
time="May 14 08:08:22" level=error msg="Request failed: Get 1/register/node: unsupported protocol scheme \"\""
time="May 14 08:08:27" level=error msg="Request failed: Get 1/register/node: unsupported protocol scheme \"\""
time="May 14 08:08:32" level=info msg="Starting Poller"
time="May 14 08:08:32" level=error msg="Request failed: Get 1/register/node: unsupported protocol scheme \"\""
time="May 14 08:08:37" level=error msg="Request failed: Get 1/register/node: unsupported protocol scheme \"\""
time

you most likely have something fighting with tyke on the ports.

check the processes you have running and on which ports. I would recommend you stop the tyk-gateway and tyk-dashboard services first just so the results are definitive.

[ec2-user@ip-XXX-XXX-XXX-XXX log]$ netstat -lntu
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:10000               0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      
tcp        0      0 127.0.0.1:27017             0.0.0.0:*                   LISTEN      
tcp        0      0 127.0.0.1:6379              0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:48748               0.0.0.0:*                   LISTEN      
tcp        0      0 :::111                      :::*                        LISTEN      
tcp        0      0 :::22                       :::*                        LISTEN      
tcp        0      0 :::3000                     :::*                        LISTEN      
tcp        0      0 :::49316                    :::*                        LISTEN      
tcp        0      0 :::5000                     :::*                        LISTEN      
udp        0      0 0.0.0.0:111                 0.0.0.0:*                               
udp        0      0 0.0.0.0:626                 0.0.0.0:*                               
udp        0      0 172.31.28.181:123           0.0.0.0:*                               
udp        0      0 127.0.0.1:123               0.0.0.0:*                               
udp        0      0 0.0.0.0:123                 0.0.0.0:*                               
udp        0      0 127.0.0.1:659               0.0.0.0:*                               
udp        0      0 0.0.0.0:10000               0.0.0.0:*                               
udp        0      0 0.0.0.0:68                  0.0.0.0:*                               
udp        0      0 0.0.0.0:50250               0.0.0.0:*                               
udp        0      0 :::111                      :::*                                    
udp        0      0 :::626                      :::*                                    
udp        0      0 :::41029                    :::*  

created a new port for the gateway (5000 on this install is used by something else for some reason). Update tyk.conf and tyke_analytics.conf

restarted the services and everything came together really well.

Finally just check your rewrite rules on NGINX to make sure they are pointing everything in the right direction.

1 Like