Over a million developers have joined DZone.

Setting Up Tyk Portal and Developer Registrations

This tutorial will show you how to get around a bug in Tyk that prevents you from using custom domains as portals.

Today’s data climate is fast-paced and it’s not slowing down. Here’s why your current integration solution is not enough. Brought to you in partnership with Liaison Technologies.

There was this long-running bug that was hitting us when we tried setting up a Tyk portal. The issue was with Tyk not allowing custom domains to be set up as portals. While the settings, as advised by Tyk, mention the dashboard and portal port as 3000, ideally, it should be set as 80 to get the portal configured seamlessly. I learned the hard way after so many attempts of getting this done on port 3000.


Image titleSetting up Portal Domain


Add to /etc/hosts File

  • 127.0.0.1 dashboard.tyk-local.com

  • 127.0.0.1 portal.tyk-local.com

Most likely, Apache2 or some other web server is already be listening to port 80. Make sure to stop those listeners to free up the port.


Stop Apache2 Web Server

 /etc/init.d/apache2 stop 


Configure the Tyk Gateway


sudo /opt/tyk-gateway/install/setup.sh 
--dashboard=http://dashboard.tyk-local.com 
--listenport=8080 
--redishost=localhost 
--redisport=6379 
--domain=""


Configure the Tyk Dashboard


sudo /opt/tyk-dashboard/install/setup.sh 
--listenport=80 
--redishost=localhost 
--redisport=6379 
--mongo=mongodb://127.0.0.1/tyk_analytics 
--tyk_api_hostname=127.0.0.1 
--tyk_node_hostname=http://127.0.0.1 
--tyk_node_port=8080 
--portal_root=/portal 
--domain="dashboard.tyk-local.com"


Configure the Tyk Pump


sudo /opt/tyk-pump/install/setup.sh 
--redishost=localhost 
--redisport=6379 
--mongo=mongodb://127.0.0.1/tyk_analytics


Initial Start to Set Up the Tyk License


sudo service tyk-pump start
sudo service tyk-dashboard start


Access http://dashboard.tyk-local.com/ and add the license in the prompt.

Restart the Tyk Dashboard and start the Tyk Gateway


sudo service tyk-dashboard restart
sudo service tyk-gateway start


Fix the Tyk Bootstrap Script to Listen to Port 80

Edit /opt/tyk-dashboard/install/bootstrap.sh and remove :3000 from all references — we're going to use port 80 as the default for the dashboard.


#!/bin/bash
# Usage ./bootstrap.sh DASHBOARD_HOSTNAME

LOCALIP=$1
RANDOM_USER=$(env LC_CTYPE=C tr -dc "a-z0-9" < /dev/urandom | head -c 10)
PASS="test123"

echo "Creating Organisation"
ORGDATA=$(curl --silent --header "admin-auth: 12345" --header "Content-Type:application/json" --data '{"owner_name": "Default Org.","owner_slug": "default", "cname_enabled": true, "cname": ""}' http://$LOCALIP/admin/organisations 2>&1)
#echo $ORGDATA

ORGID=$(echo $ORGDATA | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["Meta"]')
echo "ORGID: $ORGID"
echo "Adding new user"
USER_DATA=$(curl --silent --header "admin-auth: 12345" --header "Content-Type:application/json" --data '{"first_name": "John","last_name": "Smith","email_address": "'$RANDOM_USER'@default.com","password":"'$PASS'", "active": true,"org_id": "'$ORGID'"}' http://$LOCALIP/admin/users 2>&1)
#echo $USER_DATA

USER_CODE=$(echo $USER_DATA | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["Message"]')
echo "USER AUTH: $USER_CODE"
USER_LIST=$(curl --silent --header "authorization: $USER_CODE" http://$LOCALIP/api/users 2>&1)
#echo $USER_LIST

USER_ID=$(echo $USER_LIST | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["users"][0]["id"]')
echo "NEW ID: $USER_ID"
echo "Setting password"
OK=$(curl --silent --header "authorization: $USER_CODE" --header "Content-Type:application/json" http://$LOCALIP/api/users/$USER_ID/actions/reset --data '{"new_password":"'$PASS'"}')

echo ""
echo "DONE"
echo "===="
echo "Login at http://$LOCALIP/"
echo "User: $RANDOM_USER@default.com"
echo "Pass: $PASS"
echo ""


Save and Exit the Bootstrap Script, then Execute


sudo /opt/tyk-dashboard/install/bootstrap.sh dashboard.tyk-local.com


root@llovizna:/home/pradeeban#  sudo /opt/tyk-dashboard/install/bootstrap.sh dashboard.tyk-local.com

Creating Organisation
ORGID: 579794145ee8571e46000001
Adding new user
USER AUTH: 6936a780a8e448fd73e3d7ef64eb8059
NEW ID: 5797941458149ac06a14e801
Setting password

DONE

====

Login at http://dashboard.tyk-local.com/
User: c9og13fnc8@default.com
Pass: test123


Image title

Tyk Developer Portal


Now, you are good to log into the Tyk dashboard with the given credentials.

Set Portal Domain

 portal.tyk-local.com 

This would give you a message, "CNAME updated."

Now if you access http://portal.tyk-local.com/portal/ it would say, "Home page not found." This is expected as you have not set up the portal and the welcome page yet. 

Follow this document to get those set up.

Once you have set this up, your portal is ready for developers to register, log in, and consumes the APIs defined in the API catalogue.

Is iPaaS solving the right problems? Not knowing the fundamental difference between iPaaS and iPaaS+ could cost you down the road. Brought to you in partnership with Liaison Technologies.

Topics:
custom ,web server ,portal ,dashboard

Published at DZone with permission of Pradeeban Kathiravelu, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}