Nginx 404 Error [SOLVED]

I have had a very strange error setting up TYK.

Incoming requests are handled by NGINX listening on port 80

The base config for NGINX contains:

 # Enumerate all the Tyk servers here
   upstream tyk {
       server 127.0.0.1:5000;
}
   upstream dashboard {
       server 127.0.0.1:3000;
}

There are 3 subdomains for portal, gateway and dashboard that run a proxy pass to the servers above. They will do:

   location / {
    
       #rewrite /(.*) /[API_LISTEN_PATH]/$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;
}

If I enter:

http://dashboard.mydomain.com

I get a 404 not found error

http://dashboard.mydomain.com:3000

Displays the dashboard the page.

I setup the dashboard using:

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

I setup the gateway with:

sudo /opt/tyk-gateway/install/setup.sh --dashboard=1 --listenport=8080 --redishost=localhost --redisport=6379 --domain="" --mongo=mongodb://127.0.0.1:27017/tyk_analytics

I have tried any number of combinations to try and get this working but I am at a total loss now and chasing my tail so I thought I would see if there was anyone who could help me find my mistake

:slight_smile:

Thanks

If you are using NGinX, then I’d switch off the hostname handling in Tyk and dashboard completely (enable_host_names:false IIRC in tyk_analytics.conf)

If tyk dashboard is binding to a domain it’s very strict, and it includes the port number in its matching - NGinX will be forwarding the hostname without the port number so Tyk won’t match properly.

In one fell swoop Martin solves a nagging problem and causes me to lose a bet re: cheesecake for dessert.

Thanks Martin. Really great software, looking forward to giving it gears.

ta

1 Like