-
Notifications
You must be signed in to change notification settings - Fork 36
/
nginx.yml
89 lines (84 loc) · 2.15 KB
/
nginx.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
apiVersion: v1
kind: Service
metadata:
name: nginx
spec:
selector:
app: nginx
# This needs to be a NodePort so that our ingress controller in GCP can access the service
# Not needed in ingress-controller in minikube
type: NodePort
ports:
- protocol: "TCP"
nodePort: 32111
port: 80
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
app: nginx
name: nginx
spec:
replicas: 1
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
volumeMounts:
- name: nginx-configs
mountPath: /etc/nginx/conf.d
# A health check is need for GCP and other ingress controllers to route
# traffic to a pod
livenessProbe:
httpGet:
path: /
port: 80
# Load the configuration files for nginx
volumes:
- name: nginx-configs
configMap:
name: nginx-config
---
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-config
data:
default.conf: |
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
# Add upstream for letsencrypt job
upstream letsencrypt {
server letsencrypt:80 max_fails=0 fail_timeout=1s;
}
server {
listen 80;
listen [::]:80;
server_name _;
location / {
add_header Content-Type text/plain;
return 200 "Kubernetes + Let's encrypt demo. This should be accessible through https!";
}
# Redirect all traffic in /.well-known/ to lets encrypt
location ^~ /.well-known/acme-challenge/ {
proxy_pass http://letsencrypt;
proxy_http_version 1.1;
proxy_set_header upgrade $http_upgrade;
proxy_set_header connection $connection_upgrade;
proxy_set_header Host $http_host;
proxy_set_header x-forwarded-host $http_host;
proxy_set_header x-real-ip $remote_addr;
proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
proxy_set_header x-forwarded-protocol $scheme;
proxy_set_header x-forwarded-proto $scheme;
}
}