feat: nginx ingress controller forward real ip
This commit is contained in:
71
deployment/real-ip.yaml
Normal file
71
deployment/real-ip.yaml
Normal file
@@ -0,0 +1,71 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: real-ip
|
||||
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
namespace: real-ip
|
||||
name: real-ip
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: real-ip
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: real-ip
|
||||
spec:
|
||||
containers:
|
||||
- name: system
|
||||
image: repo.me/build/test/real-ip:v01
|
||||
imagePullPolicy: IfNotPresent
|
||||
command: ["/app/real-ip_app"]
|
||||
ports:
|
||||
- containerPort: 80
|
||||
resources:
|
||||
limits:
|
||||
memory: 10Mi
|
||||
cpu: 1
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
namespace: real-ip
|
||||
name: real-ip
|
||||
spec:
|
||||
selector:
|
||||
app: real-ip
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- name: real-ip-http
|
||||
port: 80
|
||||
targetPort: 80
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: ing-real-ip
|
||||
namespace: real-ip
|
||||
annotations:
|
||||
nginx.ingress.kubernetes.io/ssl-redirect: "false"
|
||||
nginx.ingress.kubernetes.io/use-regex: "true"
|
||||
nginx.ingress.kubernetes.io/rewrite-target: /api/real-ip/$2
|
||||
spec:
|
||||
ingressClassName: nginx
|
||||
rules:
|
||||
- host: "real-ip.zyp.dev.com"
|
||||
http:
|
||||
paths:
|
||||
- path: /api/real-ip(/|$)(.*)
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: real-ip
|
||||
port:
|
||||
number: 80
|
||||
Reference in New Issue
Block a user