222 lines
7.0 KiB
YAML
222 lines
7.0 KiB
YAML
apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: nginx-config
|
|
namespace: syncthing
|
|
data:
|
|
default.conf: |
|
|
server {
|
|
listen 80;
|
|
server_name _;
|
|
|
|
# Landing page
|
|
location = / {
|
|
root /usr/share/nginx/html;
|
|
try_files /index.html =404;
|
|
}
|
|
|
|
# NAS instance
|
|
location /nas {
|
|
rewrite ^/nas$ /nas/ permanent;
|
|
}
|
|
|
|
location /nas/ {
|
|
proxy_pass http://syncthing-nas:8384/;
|
|
|
|
# Important: tell syncthing that we're using /nas as base path
|
|
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;
|
|
|
|
# Handle websockets
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
|
|
# Sub filter to fix asset paths
|
|
sub_filter 'href="/' 'href="/nas/';
|
|
sub_filter 'src="/' 'src="/nas/';
|
|
sub_filter 'url(/' 'url(/nas/';
|
|
sub_filter '"/meta' '"/nas/meta';
|
|
sub_filter '"/rest' '"/nas/rest';
|
|
sub_filter '"/vendor' '"/nas/vendor';
|
|
sub_filter '"/theme-assets' '"/nas/theme-assets';
|
|
sub_filter '"/syncthing' '"/nas/syncthing';
|
|
# Add back button before logo
|
|
sub_filter '<img class="logo hidden-xs"' '<a href="/" class="btn btn-sm btn-default" style="margin-right: 10px; vertical-align: middle;">← Back</a><img class="logo hidden-xs"';
|
|
sub_filter_once off;
|
|
sub_filter_types text/html text/css application/javascript;
|
|
}
|
|
|
|
# Master instance
|
|
location /master {
|
|
rewrite ^/master$ /master/ permanent;
|
|
}
|
|
|
|
location /master/ {
|
|
proxy_pass http://syncthing-master: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;
|
|
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
|
|
sub_filter 'href="/' 'href="/master/';
|
|
sub_filter 'src="/' 'src="/master/';
|
|
sub_filter 'url(/' 'url(/master/';
|
|
sub_filter '"/meta' '"/master/meta';
|
|
sub_filter '"/rest' '"/master/rest';
|
|
sub_filter '"/vendor' '"/master/vendor';
|
|
sub_filter '"/theme-assets' '"/master/theme-assets';
|
|
sub_filter '"/syncthing' '"/master/syncthing';
|
|
# Add back button before logo
|
|
sub_filter '<img class="logo hidden-xs"' '<a href="/" class="btn btn-sm btn-default" style="margin-right: 10px; vertical-align: middle;">← Back</a><img class="logo hidden-xs"';
|
|
sub_filter_once off;
|
|
sub_filter_types text/html text/css application/javascript;
|
|
}
|
|
|
|
# Iris instance
|
|
location /iris {
|
|
rewrite ^/iris$ /iris/ permanent;
|
|
}
|
|
|
|
location /iris/ {
|
|
proxy_pass http://syncthing-khv: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;
|
|
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
|
|
sub_filter 'href="/' 'href="/iris/';
|
|
sub_filter 'src="/' 'src="/iris/';
|
|
sub_filter 'url(/' 'url(/iris/';
|
|
sub_filter '"/meta' '"/iris/meta';
|
|
sub_filter '"/rest' '"/iris/rest';
|
|
sub_filter '"/vendor' '"/iris/vendor';
|
|
sub_filter '"/theme-assets' '"/iris/theme-assets';
|
|
sub_filter '"/syncthing' '"/iris/syncthing';
|
|
# Add back button before logo
|
|
sub_filter '<img class="logo hidden-xs"' '<a href="/" class="btn btn-sm btn-default" style="margin-right: 10px; vertical-align: middle;">← Back</a><img class="logo hidden-xs"';
|
|
sub_filter_once off;
|
|
sub_filter_types text/html text/css application/javascript;
|
|
}
|
|
}
|
|
|
|
index.html: |
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Syncthing Instances</title>
|
|
<style>
|
|
body {
|
|
font-family: Arial, sans-serif;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
height: 100vh;
|
|
margin: 0;
|
|
background-color: #f0f0f0;
|
|
}
|
|
.container {
|
|
text-align: center;
|
|
background: white;
|
|
padding: 40px;
|
|
border-radius: 10px;
|
|
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
|
}
|
|
h1 {
|
|
color: #333;
|
|
margin-bottom: 30px;
|
|
}
|
|
.links {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 15px;
|
|
}
|
|
a {
|
|
display: inline-block;
|
|
padding: 15px 30px;
|
|
background-color: #0078e7;
|
|
color: white;
|
|
text-decoration: none;
|
|
border-radius: 5px;
|
|
transition: background-color 0.3s;
|
|
}
|
|
a:hover {
|
|
background-color: #0056b3;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<h1>Syncthing Instances</h1>
|
|
<div class="links">
|
|
<a href="/nas/">NAS Instance</a>
|
|
<a href="/master/">Master Instance</a>
|
|
<a href="/iris/">Iris Instance</a>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|
|
---
|
|
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
|
|
- name: html
|
|
mountPath: /usr/share/nginx/html
|
|
volumes:
|
|
- name: config
|
|
configMap:
|
|
name: nginx-config
|
|
items:
|
|
- key: default.conf
|
|
path: default.conf
|
|
- name: html
|
|
configMap:
|
|
name: nginx-config
|
|
items:
|
|
- key: index.html
|
|
path: index.html
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: syncthing-router
|
|
namespace: syncthing
|
|
spec:
|
|
selector:
|
|
app: syncthing-router
|
|
ports:
|
|
- protocol: TCP
|
|
port: 80
|
|
targetPort: 80 |