From b8cacf3a7f141a77c6e45fcf9b9b3c3203d5e04e Mon Sep 17 00:00:00 2001
From: Jeremy MANSON <jeremy-manson@jmanson.fr>
Date: Mon, 7 Mar 2016 14:42:30 +0100
Subject: [PATCH] webui2 configuration

installation and configuration of shinken nginx for webui
---
 conf/broker-master.cfg | 50 ++++++++++++++++++++++++++++++++++++++++++
 conf/nginx.conf        | 34 +++++++++++++++++++++++++---
 conf/webui2.cfg        |  9 ++++++++
 3 files changed, 90 insertions(+), 3 deletions(-)
 create mode 100644 conf/broker-master.cfg
 create mode 100644 conf/webui2.cfg

diff --git a/conf/broker-master.cfg b/conf/broker-master.cfg
new file mode 100644
index 0000000..3c97323
--- /dev/null
+++ b/conf/broker-master.cfg
@@ -0,0 +1,50 @@
+#===============================================================================
+# BROKER (S1_Broker)
+#===============================================================================
+# Description: The broker is responsible for:
+# - Exporting centralized logs of all Shinken daemon processes
+# - Exporting status data
+# - Exporting performance data
+# - Exposing Shinken APIs:
+#   - Status data
+#   - Performance data
+#   - Configuration data
+#   - Command interface
+# https://shinken.readthedocs.org/en/latest/08_configobjects/broker.html
+#===============================================================================
+define broker {
+    broker_name     broker-master
+    address         localhost
+    port            7772
+    spare           0
+
+    ## Optional
+    manage_arbiters     1   ; Take data from Arbiter. There should be only one
+                            ; broker for the arbiter.
+    manage_sub_realms   1   ; Does it take jobs from schedulers of sub-Realms?
+    timeout             3   ; Ping timeout
+    data_timeout        120 ; Data send timeout
+    max_check_attempts  3   ; If ping fails N or more, then the node is dead
+    check_interval      60  ; Ping node every N seconds
+
+    ## Modules
+    # Default: None
+    # Interesting modules that can be used:
+    # - simple-log              = just all logs into one file
+    # - livestatus              = livestatus listener
+    # - tondodb-mysql           = NDO DB support (deprecated)
+    # - npcdmod                 = Use the PNP addon
+    # - graphite                = Use a Graphite time series DB for perfdata
+    # - webui                   = Shinken Web interface
+    # - glpidb                  = Save data in GLPI MySQL database
+    modules     webui2
+
+    # Enable https or not
+    use_ssl               0
+    # enable certificate/hostname check, will avoid man in the middle attacks
+    hard_ssl_name_check   0
+
+    ## Advanced
+    realm   All
+}
+
diff --git a/conf/nginx.conf b/conf/nginx.conf
index 0232df8..7044194 100644
--- a/conf/nginx.conf
+++ b/conf/nginx.conf
@@ -1,3 +1,31 @@
-location /shinken {
-    proxy_pass http://127.0.0.1:7767;
-}
\ No newline at end of file
+
+    }
+    location @webui {
+        root /var/lib/shinken/modules/webui2/;
+    }
+
+    location ~* ^/(all|forms|inner|static|dashboard|availability|logs|widget|cv|user|modal|gotfirstdata|host/cv)$
+        return 301 /shinken$request_uri;
+    }
+
+    location /shinken/ {
+        # Set the variables so that the WebUI will
+        # know what hostname it has, this is useful for redirects
+        proxy_set_header   X-NginX-Proxy true;
+        proxy_set_header   X-Real-IP $remote_addr;
+        proxy_set_header   Host      $http_host;
+        #proxy_set_header   Host      $host;
+        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
+        proxy_set_header   X-Forwarded-Proto $scheme;
+
+
+        # Replace 7767 (default) by the port your shinken webui is listening on
+        proxy_pass http://localhost:7767/;
+        proxy_redirect default;
+
+        # Sub_filter all the occurrences of the page
+        sub_filter_once off;
+
+        # All patterns that should be rewritten
+        sub_filter "href=\"/" "href=\"/shinken/";
+    }
diff --git a/conf/webui2.cfg b/conf/webui2.cfg
new file mode 100644
index 0000000..83bdf6a
--- /dev/null
+++ b/conf/webui2.cfg
@@ -0,0 +1,9 @@
+define module {
+   module_name         webui2
+   module_type         webui2
+   uri                        mongodb://localhost
+   modules ui-pnp
+   auth_secret                CHANGEME
+   login_text                 Login to the Shinken WebUI - Live System
+}
+