mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-09-04 09:21:42 +02:00
Replaced nginx native with openresty for logout injection. Right now still buggy on nextcloud and espocrm
This commit is contained in:
@@ -10,12 +10,17 @@
|
||||
name: srv-web-7-7-inj-matomo
|
||||
when: applications | get_app_conf(application_id, 'features.matomo', False)
|
||||
|
||||
- name: "Activate Portfolio iFrame Notifier for {{ domain }}"
|
||||
- name: "Activate Portfolio iFrame notifier for {{ domain }}"
|
||||
include_role:
|
||||
name: srv-web-7-7-inj-iframe
|
||||
name: srv-web-7-7-inj-port-ui-desktop
|
||||
when: applications | get_app_conf(application_id, 'features.port-ui-desktop', False)
|
||||
|
||||
- name: "Activate Javascript for {{ domain }}"
|
||||
include_role:
|
||||
name: srv-web-7-7-inj-javascript
|
||||
when: applications | get_app_conf(application_id, 'features.javascript', False)
|
||||
|
||||
- name: "Activate logout proxy for {{ domain }}"
|
||||
include_role:
|
||||
name: srv-web-7-7-inj-logout
|
||||
when: applications | get_app_conf(application_id, 'features.logout', False)
|
||||
|
@@ -1,33 +0,0 @@
|
||||
{# Allow multiple sub_filters #}
|
||||
sub_filter_once off;
|
||||
sub_filter_types text/html;
|
||||
|
||||
{% set modifier_css_enabled = applications | get_app_conf(application_id, 'features.css', False) %}
|
||||
{% set modifier_matomo_enabled = applications | get_app_conf(application_id, 'features.matomo', False) %}
|
||||
{% set modifier_iframe_enabled = applications | get_app_conf(application_id, 'features.port-ui-desktop', False) %}
|
||||
{% set modifier_javascript_enabled = applications | get_app_conf(application_id, 'features.javascript', False) %}
|
||||
|
||||
{% if modifier_iframe_enabled or modifier_css_enabled or modifier_matomo_enabled or modifier_javascript_enabled %}
|
||||
sub_filter '</head>' '
|
||||
{%- if modifier_css_enabled -%}
|
||||
{%- include "roles/srv-web-7-7-inj-css/templates/head_sub.j2" -%}
|
||||
{%- endif -%}
|
||||
{%- if modifier_matomo_enabled -%}
|
||||
{%- include "roles/srv-web-7-7-inj-matomo/templates/head_sub.j2" -%}
|
||||
{%- endif -%}
|
||||
{%- if modifier_iframe_enabled -%}
|
||||
{%- include "roles/srv-web-7-7-inj-iframe/templates/head_sub.j2" -%}
|
||||
{%- endif -%}
|
||||
{%- if modifier_javascript_enabled -%}
|
||||
{%- include "roles/srv-web-7-7-inj-javascript/templates/head_sub.j2" -%}
|
||||
{%- endif -%}
|
||||
</head>';
|
||||
{% endif %}
|
||||
|
||||
{% if modifier_css_enabled | bool %}
|
||||
{% include 'roles/srv-web-7-7-inj-css/templates/location.conf.j2' %}
|
||||
{% endif %}
|
||||
|
||||
{% if modifier_matomo_enabled %}
|
||||
{% include 'roles/srv-web-7-7-inj-matomo/templates/matomo-tracking.conf.j2' %}
|
||||
{% endif %}
|
@@ -0,0 +1,52 @@
|
||||
{% set modifier_css_enabled = applications | get_app_conf(application_id, 'features.css', false) | bool %}
|
||||
{% if modifier_css_enabled %}
|
||||
{%- include 'roles/srv-web-7-7-inj-css/templates/location.conf.j2' -%}
|
||||
{% endif %}
|
||||
|
||||
lua_need_request_body on;
|
||||
|
||||
body_filter_by_lua_block {
|
||||
-- initialize buffer
|
||||
ngx.ctx.buf = ngx.ctx.buf or {}
|
||||
local chunk, eof = ngx.arg[1], ngx.arg[2]
|
||||
|
||||
if chunk ~= "" then
|
||||
table.insert(ngx.ctx.buf, chunk)
|
||||
end
|
||||
|
||||
if not eof then
|
||||
ngx.arg[1] = nil
|
||||
return
|
||||
end
|
||||
|
||||
-- on eof: concatenate and reset buffer
|
||||
local whole = table.concat(ngx.ctx.buf)
|
||||
ngx.ctx.buf = nil
|
||||
|
||||
-- build head-injection snippets
|
||||
local head_snippets = {}
|
||||
|
||||
{% for head_feature in ['css', 'matomo', 'port-ui-desktop', 'javascript', 'logout'] %}
|
||||
{% if applications | get_app_conf(application_id, 'features.' ~ head_feature, false) | bool %}
|
||||
head_snippets[#head_snippets + 1] = [=[
|
||||
{%- include "roles/srv-web-7-7-inj-" ~ head_feature ~ "/templates/head_sub.j2" -%}
|
||||
]=]
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
-- inject into </head>
|
||||
local head_payload = table.concat(head_snippets, "\n") .. "</head>"
|
||||
whole = string.gsub(whole, "</head>", head_payload)
|
||||
|
||||
{% if applications | get_app_conf(application_id, 'features.matomo', false) | bool %}
|
||||
-- build Matomo noscript tracking for body
|
||||
local body_matomo = [=[
|
||||
{%- include 'roles/srv-web-7-7-inj-matomo/templates/body_sub.j2' -%}
|
||||
]=]
|
||||
|
||||
-- inject before </body>
|
||||
whole = string.gsub(whole, "</body>", body_matomo)
|
||||
{% endif %}
|
||||
|
||||
ngx.arg[1] = whole
|
||||
}
|
Reference in New Issue
Block a user