summaryrefslogtreecommitdiff
path: root/configs/nginx
diff options
context:
space:
mode:
Diffstat (limited to 'configs/nginx')
-rw-r--r--configs/nginx/listen-http.conf2
-rw-r--r--configs/nginx/listen-https.conf3
-rw-r--r--configs/nginx/nginx.conf.mako (renamed from configs/nginx/nginx.conf)35
-rw-r--r--configs/nginx/redirect-to-https.conf3
4 files changed, 32 insertions, 11 deletions
diff --git a/configs/nginx/listen-http.conf b/configs/nginx/listen-http.conf
deleted file mode 100644
index 76cb18d2..00000000
--- a/configs/nginx/listen-http.conf
+++ /dev/null
@@ -1,2 +0,0 @@
-listen 80;
-listen [::]:80;
diff --git a/configs/nginx/listen-https.conf b/configs/nginx/listen-https.conf
deleted file mode 100644
index db2f68e3..00000000
--- a/configs/nginx/listen-https.conf
+++ /dev/null
@@ -1,3 +0,0 @@
-listen 443 ssl;
-listen [::]:443 ssl;
-http2 on;
diff --git a/configs/nginx/nginx.conf b/configs/nginx/nginx.conf.mako
index 16e8da3c..65b46db1 100644
--- a/configs/nginx/nginx.conf
+++ b/configs/nginx/nginx.conf.mako
@@ -36,16 +36,45 @@ http {
include /etc/kvmd/nginx/kvmd.ctx-http.conf;
include /usr/share/kvmd/extras/*/nginx.ctx-http.conf;
+ % if https_enabled:
+
server {
- include /etc/kvmd/nginx/listen-http.conf;
+ listen ${http_port};
+ % if ipv6_enabled:
+ listen [::]:${http_port};
+ % endif
include /etc/kvmd/nginx/certbot.ctx-server.conf;
- include /etc/kvmd/nginx/redirect-to-https.conf;
+ location / {
+ % if https_port == 443:
+ return 301 https://$host$request_uri;
+ % else:
+ return 301 https://$host:${https_port}$request_uri;
+ % endif
+ }
}
server {
- include /etc/kvmd/nginx/listen-https.conf;
+ listen ${https_port} ssl;
+ % if ipv6_enabled:
+ listen [::]:${https_port} ssl;
+ % endif
+ http2 on;
include /etc/kvmd/nginx/ssl.conf;
include /etc/kvmd/nginx/kvmd.ctx-server.conf;
include /usr/share/kvmd/extras/*/nginx.ctx-server.conf;
}
+
+ % else:
+
+ server {
+ listen ${http_port};
+ % if ipv6_enabled:
+ listen [::]:${http_port};
+ % endif
+ include /etc/kvmd/nginx/certbot.ctx-server.conf;
+ include /etc/kvmd/nginx/kvmd.ctx-server.conf;
+ include /usr/share/kvmd/extras/*/nginx.ctx-server.conf;
+ }
+
+ % endif
}
diff --git a/configs/nginx/redirect-to-https.conf b/configs/nginx/redirect-to-https.conf
deleted file mode 100644
index 385fb49a..00000000
--- a/configs/nginx/redirect-to-https.conf
+++ /dev/null
@@ -1,3 +0,0 @@
-location / {
- return 301 https://$host$request_uri;
-}