How Nginx‑Ingress Transforms Ingress Resources into Nginx Configurations
This article explains how a Kubernetes nginx‑ingress pod acts as a gateway, converting Ingress YAML definitions into Nginx upstream and server blocks, and shows the necessary deployment and service configurations for exposing HTTP and HTTPS traffic.
Host Nginx
General Nginx reverse proxy configuration example:
upstream order{
server 192.168.1.10:5001;
server 192.168.1.11:5001;
}
server {
listen 80;
server_name order.example.com;
access_log /var/log/nginx/order.example.com-access.log;
error_log /var/log/nginx/order.example.com-error.log;
location / {
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_pass http://order;
}
}192.168.1.10:5001 and 192.168.1.11:5001 are the service endpoints (e.g., the order service).
pod nginx‑ingress
nginx‑ingress is a pod that serves as a gateway, forwarding external traffic to internal services via an embedded Nginx instance.
1. Pod
The pod contains two components: a controller and Nginx.
controller: communicates with the Kubernetes API to update Nginx configuration (based on Ingress resources). nginx: performs the normal reverse‑proxy function.
Unlike a host‑based Nginx, this pod runs inside Kubernetes; its configuration is defined in a Deployment YAML.
https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/mandatory.yamlA snippet of the deployment shows the container ports that are exposed:
- name: http
containerPort: 80
- name: https
containerPort: 4432. Ingress resource
Ingress resources are managed via YAML, for example:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: order
spec:
rules:
- host: order.example.com
http:
paths: /
backend:
serviceName: order
servicePort: 80This rule directs all external requests to the internal order service on port 80.
The controller converts the Ingress into an Nginx upstream and server block:
upstream order{
server order:80;
}
server {
listen 80;
server_name order.example.com;
...
location / {
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_pass http://order; # corresponds to Ingress name: order
}
}If HTTPS is used, additional configuration for port 443 and certificates is generated (not shown).
3. Exposing nginx‑ingress
Typically a Service of type NodePort is created to expose the pod externally.
4. Workflow
Because the pod proxies all services, scaling the number of nginx‑ingress pods is required for high‑traffic scenarios.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
