diff --git a/www/nginx/Makefile b/www/nginx/Makefile
index 87191c8e4..1263c9d33 100644
--- a/www/nginx/Makefile
+++ b/www/nginx/Makefile
@@ -1,8 +1,7 @@
PLUGIN_NAME= nginx
-PLUGIN_VERSION= 0.4
+PLUGIN_VERSION= 1.1
PLUGIN_COMMENT= Nginx HTTP server and reverse proxy
PLUGIN_DEPENDS= nginx
PLUGIN_MAINTAINER= franz.fabian.94@gmail.com
-PLUGIN_DEVEL= yes
.include "../../Mk/plugins.mk"
diff --git a/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/Api/SettingsController.php b/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/Api/SettingsController.php
index 28f5eb716..bc9045993 100644
--- a/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/Api/SettingsController.php
+++ b/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/Api/SettingsController.php
@@ -278,4 +278,31 @@ class SettingsController extends ApiMutableModelControllerBase
{
return $this->setBase('httprewrite', 'http_rewrite', $uuid);
}
+
+ // http security headers
+ public function searchsecurity_headerAction()
+ {
+ return $this->searchBase('security_header', array('description'));
+ }
+
+ public function getsecurity_headerAction($uuid = null)
+ {
+ $this->sessionClose();
+ return $this->getBase('security_header', 'security_header', $uuid);
+ }
+
+ public function addsecurity_headerAction()
+ {
+ return $this->addBase('security_header', 'security_header');
+ }
+
+ public function delsecurity_headerAction($uuid)
+ {
+ return $this->delBase('security_header', $uuid);
+ }
+
+ public function setsecurity_headerAction($uuid)
+ {
+ return $this->setBase('security_header', 'security_header', $uuid);
+ }
}
diff --git a/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/IndexController.php b/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/IndexController.php
index d6a445284..027d7c216 100644
--- a/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/IndexController.php
+++ b/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/IndexController.php
@@ -49,6 +49,7 @@ class IndexController extends \OPNsense\Base\IndexController
$this->view->httprewrite = $this->getForm("httprewrite");
$this->view->naxsi_rule = $this->getForm("naxsi_rule");
$this->view->naxsi_custom_policy = $this->getForm("naxsi_custom_policy");
+ $this->view->security_headers = $this->getForm("security_headers");
$this->view->pick('OPNsense/Nginx/index');
}
}
diff --git a/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/forms/httpserver.xml b/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/forms/httpserver.xml
index 1a455d735..67e2eb3c4 100644
--- a/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/forms/httpserver.xml
+++ b/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/forms/httpserver.xml
@@ -89,4 +89,9 @@
checkbox
Allow the daemon to use the sendfile function.
+
+ httpserver.security_header
+
+ dropdown
+
diff --git a/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/forms/security_headers.xml b/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/forms/security_headers.xml
new file mode 100644
index 000000000..78e7c40dd
--- /dev/null
+++ b/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/forms/security_headers.xml
@@ -0,0 +1,547 @@
+
diff --git a/www/nginx/src/opnsense/mvc/app/models/OPNsense/Nginx/Nginx.xml b/www/nginx/src/opnsense/mvc/app/models/OPNsense/Nginx/Nginx.xml
index 8ef5a9098..fe06656c1 100644
--- a/www/nginx/src/opnsense/mvc/app/models/OPNsense/Nginx/Nginx.xml
+++ b/www/nginx/src/opnsense/mvc/app/models/OPNsense/Nginx/Nginx.xml
@@ -1,5 +1,6 @@
//OPNsense/Nginx
+ 1.1.0
nginx web server, reverse proxy and waf
@@ -459,6 +460,18 @@
1
Y
+
+
+
+ OPNsense.Nginx.Nginx
+ security_header
+ description
+
+
+ Selected security rule not found
+ N
+ N
+
@@ -484,5 +497,336 @@
+
+
+ Y
+
+
+ N
+
+ No Referrer
+ No Refer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 0
+
+
+ Y
+ 0
+
+
+ Y
+ 0
+
+
+ Y
+ 0
+
+
+ N
+
+
+ Y
+ 0
+
+
+ Y
+ 0
+
+
+ Y
+ 0
+
+
+ Y
+ 0
+
+
+ Y
+ 0
+
+
+ Y
+ 0
+
+
+ Y
+ 0
+
+
diff --git a/www/nginx/src/opnsense/mvc/app/views/OPNsense/Nginx/index.volt b/www/nginx/src/opnsense/mvc/app/views/OPNsense/Nginx/index.volt
index b1d8109f9..877e9cf33 100644
--- a/www/nginx/src/opnsense/mvc/app/views/OPNsense/Nginx/index.volt
+++ b/www/nginx/src/opnsense/mvc/app/views/OPNsense/Nginx/index.volt
@@ -96,6 +96,7 @@ $( document ).ready(function() {
'httpserver',
'httprewrite',
'custompolicy',
+ 'security_header',
'naxsirule'].forEach(function(element) {
$("#grid-" + element).UIBootgrid(
{ 'search':'/api/nginx/settings/search' + element,
@@ -149,6 +150,9 @@ $( document ).ready(function() {
{{ lang._('Naxsi WAF Rule')}}
+
+
+
@@ -367,6 +371,27 @@ $( document ).ready(function() {
+
@@ -380,3 +405,4 @@ $( document ).ready(function() {
{{ partial("layout_partials/base_dialog",['fields': httprewrite,'id':'httprewritedlg', 'label':lang._('Edit URL Rewrite')]) }}
{{ partial("layout_partials/base_dialog",['fields': naxsi_custom_policy,'id':'custompolicydlg', 'label':lang._('Edit WAF Policy')]) }}
{{ partial("layout_partials/base_dialog",['fields': naxsi_rule,'id':'naxsiruledlg', 'label':lang._('Edit Naxsi Rule')]) }}
+{{ partial("layout_partials/base_dialog",['fields': security_headers,'id':'security_headersdlg', 'label':lang._('Edit Security Headers')]) }}
diff --git a/www/nginx/src/opnsense/scripts/nginx/csp_report.php b/www/nginx/src/opnsense/scripts/nginx/csp_report.php
new file mode 100644
index 000000000..45770492f
--- /dev/null
+++ b/www/nginx/src/opnsense/scripts/nginx/csp_report.php
@@ -0,0 +1,23 @@
+ 0 %}
+{# only append non-empty #}
+{% do hash_csp.update({csp_category: current_list}) %}
+{% endif %}
+{% endif %}
+{% endfor %}
+ add_header Content-Security-Policy{% if security_rule.csp_report_only %}-Report-Only{% endif %} "{%
+ for key, value in hash_csp.items() %}{{ key }} {{ value|join(' ') }}; {% endfor %}{#
+ #} report-uri /opnsense-report-csp-violation" always;
+{% endif %}
\ No newline at end of file