From 2f890759c10557852b35e5103bd3ab12b10c5b38 Mon Sep 17 00:00:00 2001
From: Adar Nimrod <nimrod@shore.co.il>
Date: Fri, 8 Jan 2021 21:22:24 +0200
Subject: [PATCH] Default server redirects to www.shore.co.il.

In case the host isn't passed (or isn't known), redirect to
www.shore.co.il.
---
 conf.d/default.conf         | 12 ++++++++++++
 conf.d/www.shore.co.il.conf |  8 ++++----
 2 files changed, 16 insertions(+), 4 deletions(-)
 create mode 100644 conf.d/default.conf

diff --git a/conf.d/default.conf b/conf.d/default.conf
new file mode 100644
index 0000000..b18ffbf
--- /dev/null
+++ b/conf.d/default.conf
@@ -0,0 +1,12 @@
+server {
+    listen              80 default_server;
+    listen              [::]:80 default_server;
+    location /          { return 301 https://www.shore.co.il$request_uri; }
+}
+
+server {
+    listen              443 ssl default_server;
+    listen              [::]:443 ssl default_server;
+    include             snippets/ssl.conf;
+    location /          { return 301 https://www.shore.co.il$request_uri; }
+}
diff --git a/conf.d/www.shore.co.il.conf b/conf.d/www.shore.co.il.conf
index 4b63afe..7200f5a 100644
--- a/conf.d/www.shore.co.il.conf
+++ b/conf.d/www.shore.co.il.conf
@@ -2,8 +2,8 @@ map $host $lam { default ldap-account-manager; }
 map $host $kodi { default kodi.shore.co.il; }
 
 server {
-    listen              80 default_server;
-    listen              [::]:80 default_server;
+    listen              80;
+    listen              [::]:80;
     server_name         www.shore.co.il;
     include             snippets/robots-allow-all.conf;
     include             snippets/ads-txt.conf;
@@ -17,8 +17,8 @@ server {
 }
 
 server {
-    listen                  443 ssl default_server;
-    listen                  [::]:443 ssl default_server;
+    listen                  443 ssl;
+    listen                  [::]:443 ssl;
     server_name             www.shore.co.il;
     include                 snippets/robots-allow-all.conf;
     include                 snippets/ads-txt.conf;
-- 
GitLab