I feel like this is a basic question but I’m struggling to find anything concrete in my research. This must be a common problem and im not sure what to google.
I’m running an air gapped Kubernetes cluster with a bunch of service on whom all have UIs. My services are exposed using NodePort. I can navigate to the ui by doing ip addr:NodePort. I have DNS setup using dnsmasq so I can access the URL at example.domain.com:NodePort.
I want to “hide” the nodeport portion of the url so that users/clients can access apps at example.domain.com/appname.
Im running an Apache Webserver to serve some files and I have implemented a bunch of redirects e.g.
Redirect permanent /appname http://example.domain.com:30000/
which works semi-nicely when access the UIs via firefox browser e.g. example.domain.com/appname. This does change the URL in the users address bar but I can live with that. The problem with this is that some clients don’t automatically redirect to http://example.domain.com:30000/ and instead just present the 301 status code.
Can somebody point me in the right direction please.
Thanks
3
Answers
After seeing Ijaz answer I was able to refine my google search a little and came up with the below:
/etc/hosts
If you navigate to gitlab.domain.com you will be redirected to the correct port (30100).
The downside to this is that one has to have a domain name for every application that I deploy. I would have preferred to do something similar to:
/etc/hosts
However when I navigated to example.domain.com/gitlab it would append the correct url e.g. the landing page for gitlab is /users/sign_in, example.domain.com/users/sign_in however my browser displayed Not Found. The request URL /users/sign_in was not found on the server.
I couldnt figure out the correct configuration. If anyone has any further thoughts to fix this please let me know.
You have to redirect HTTP traffic from port 80 (which is standard) to your NodePort.
For example
Using apache or nginx , you can just use a virtual server that hides the internal ports. I dont think you need to put any redirection , you just need to serve a url to external client from virtual server :80 whos backend, upstream nodes are your internal nodes , with node ports.
You can find easy and better examples for nginx , ha-proxy and others.
Here is an apache example: