(01)Install
1sudo apt-get update && sudo apt-get install -y nginx2sudo systemctl enable nginx && sudo systemctl start nginxHigh-performance web server and reverse proxy
If you're on Kubernetes 1.27 or older
If you're on Kubernetes 1.28
Ingress-NGINX + older clusters
What is this?
Nginx serves websites to visitors and can also balance traffic across multiple backend servers.
Where to create or edit the main configuration — paths below match the setup steps.
/etc/nginx/nginx.confLocation: Linux — main config
Global nginx settings and includes
/etc/nginx/sites-available/*Location: Debian/Ubuntu vhosts
Virtual hosts and reverse proxy rules
Step 01
1sudo apt-get update && sudo apt-get install -y nginx2sudo systemctl enable nginx && sudo systemctl start nginxStep 02
1sudo nano /etc/nginx/sites-available/myapp2# server {3# listen 80;4# server_name example.com;5# location / { proxy_pass http://127.0.0.1:3000; }6# }7sudo ln -s /etc/nginx/sites-available/myapp /etc/nginx/sites-enabled/8sudo nginx -t && sudo systemctl reload nginxStep 03
1curl -I http://localhostStep 04
1sudo nginx -t && sudo systemctl reload nginxStep 05
1# Check nginx error log2sudo tail -f /var/log/nginx/error.log3# Verify backend is running4curl http://localhost:30005sudo nginx -t && sudo systemctl reload nginx3 YAML templates for Nginx. Copy and deploy after setup.
3 ready-to-copy templates. Expand one, copy the YAML, then run the deploy commands.
Ingress.yml
1apiVersion: networking.k8s.io/v12kind: Ingress3metadata:4 name: minimal-ingress5 annotations:6 nginx.ingress.kubernetes.io/rewrite-target: /7spec:8 rules:9 - http:10 paths:11 - path: /testpath12 pathType: Prefix13 backend:14 service:15 name: test16 port:17 number: 80Step 01
1kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.11.1/deploy/static/provider/cloud/deploy.yaml2kubectl wait --namespace ingress-nginx --for=condition=ready pod --selector=app.kubernetes.io/component=controller --timeout=120s1kubectl apply -f Ingress.yml2kubectl get ingress3kubectl describe ingress minimal-ingress