Answer the question
In order to leave comments, you need to log in
Kubernetes nginx reverseproxy how to deploy any examples?
Hello. I'm trying to deploy nginx reverseproxy in K8s. I have dotnet pods, I want to proxy them through nginx reverse proxy
. I don't understand how to do it.
Here is the config.
configmap
nginx.conf
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx
data:
nginx.conf: |
worker_processes 4;
events { worker_connections 1024; }
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
default_type application/octet-stream;
gzip on;
upstream hosts {
server ip:port;
server ip:port;
}
server {
listen 80;
location / {
proxy_pass http://hosts;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
}
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
spec:
selector:
matchLabels:
app: nginx
replicas: 2
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1
ports:
- name: http
containerPort: 80
volumeMounts:
- name: nginx-config
mountPath: /etc/nginx
volumes:
- name: nginx-config
configMap:
name: nginx
apiVersion: v1
kind: Service
metadata:
name: nginx
spec:
type: LoadBalancer
selector:
app: nginx
ports:
- port: 80
name: http
externalIPs:
- ip
- ip
Answer the question
In order to leave comments, you need to log in
Other things being equal, it is recommended to use ingress to publish a service in a kubernetes cluster to the outside. In fact, this will be nginx reverse proxy. One of the typical options:
https://github.com/kubernetes/ingress-nginx
https://kubernetes.github.io/ingress-nginx/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question