85 lines
2.1 KiB
YAML
85 lines
2.1 KiB
YAML
apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: nginx-router-config
|
|
namespace: syncthing
|
|
data:
|
|
default.conf: |
|
|
server {
|
|
listen 80;
|
|
server_name _;
|
|
|
|
# Route assets based on cookie or referer
|
|
location / {
|
|
# Check cookie first
|
|
if ($cookie_syncthing_instance = "nas") {
|
|
proxy_pass http://syncthing-nas:8384;
|
|
}
|
|
if ($cookie_syncthing_instance = "master") {
|
|
proxy_pass http://syncthing-master:8384;
|
|
}
|
|
if ($cookie_syncthing_instance = "iris") {
|
|
proxy_pass http://syncthing-khv:8384;
|
|
}
|
|
|
|
# Check referer as fallback
|
|
if ($http_referer ~ "/nas") {
|
|
proxy_pass http://syncthing-nas:8384;
|
|
}
|
|
if ($http_referer ~ "/master") {
|
|
proxy_pass http://syncthing-master:8384;
|
|
}
|
|
if ($http_referer ~ "/iris") {
|
|
proxy_pass http://syncthing-khv:8384;
|
|
}
|
|
|
|
# Default to nas if no match
|
|
proxy_pass http://syncthing-nas:8384;
|
|
|
|
proxy_set_header Host $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-Proto $scheme;
|
|
}
|
|
}
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: syncthing-router
|
|
namespace: syncthing
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels:
|
|
app: syncthing-router
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: syncthing-router
|
|
spec:
|
|
containers:
|
|
- name: nginx
|
|
image: nginx:alpine
|
|
ports:
|
|
- containerPort: 80
|
|
volumeMounts:
|
|
- name: config
|
|
mountPath: /etc/nginx/conf.d
|
|
volumes:
|
|
- name: config
|
|
configMap:
|
|
name: nginx-router-config
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: syncthing-router
|
|
namespace: syncthing
|
|
spec:
|
|
selector:
|
|
app: syncthing-router
|
|
ports:
|
|
- protocol: TCP
|
|
port: 80
|
|
targetPort: 80 |