You must have gotten a client where the client wants to see the results of the application work on Kubernetes, this we can use Nginx Proxy to reverse the IP service that is above Minikube to the IP private network around us. At least, if we can access it on our private network subnet, we can use the router to reverse private ip to public ip again.
I want to expose my ReactJS apps to Private Network Subnet on Minikube. So user can access my ReactJS apps on Minikube with Private Network
I have an ReactJS apps run on Minikube with port 3000
I want to access on my_private_ip:80
Ubuntu 20.04LTS
Minikube with Kubernetes Cluster Running
Nginx on Host
Some Apps on Minikube
Kubectl
Make sure your Kubernetes Cluster on Minikube has been Running.
Make sure your apps (Deployment) has been running on Kubernetes Cluster Minikube.
Make sure you have install Nginx on your Hosts OS (Ubuntu).
Don't forget you must activated minikube tunnel
.
minikube tunnel
kubectl expose deployment client-depl --type=NodePort --port=3000
minikube ip
kubectl get service client-depl
Then write your minikube ip & Service node port. You can write like this:
minikube_ip:client_depl_nodeport
for my case, i have 192.168.49.2:30683
I want to access on my_private_ip:80 so i must edit my Nginx Server Block with Proxy_Pass.
nano /etc/nginx/sites-enabled/default
server {
listen 80;
server_name _;
location / {
proxy_pass http://192.168.49.2:30683;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
server {
listen 80;
server_name _;
location / {
proxy_pass http://192.168.49.2:30683;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
See on your ubuntu network :
ifconfig
Access on your_private_ip:80
- Sign Up on ngrok first
snap install ngrok
ngrok config add-authtoken random_auth_token
ngrok http 80
- Access
access on Forwarding ngrok URL