Skip to content

Commit

Permalink
fix missing Strict-Transport-Policy header, fix X-Forwarded-Prefix wi…
Browse files Browse the repository at this point in the history
…th regex URLs and print logs when UI tests failed
  • Loading branch information
fl0ppy-d1sk committed Aug 2, 2023
1 parent 26f2852 commit bf9cd36
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/bw/lua/bunkerweb/helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ helpers.fill_ctx = function()
data.http_content_length = ngx.var.http_content_length
data.http_origin = ngx.var.http_origin
data.http_version = ngx.req.http_version()
data.scheme = ngx.var.scheme
end
-- IP data : global
local ip_is_global, err = utils.ip_is_global(data.remote_addr)
Expand Down
4 changes: 1 addition & 3 deletions src/common/core/headers/headers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ end

function headers:header()
-- Override upstream headers if needed
local ssl = self.variables["AUTO_LETS_ENCRYPT"] == "yes" or
self.variables["USE_CUSTOM_SSL"] == "yes" or
self.variables["GENERATE_SELF_SIGNED_SSL"] == "yes"
local ssl = self.ctx.bw.scheme == "https"
for variable, header in pairs(self.all_headers) do
if ngx.header[header] == nil or (self.variables[variable] ~= "" and self.variables["KEEP_UPSTREAM_HEADERS"] ~= "*" and utils.regex_match(self.variables["KEEP_UPSTREAM_HEADERS"], "(^| )" .. header .. "($| )") == nil) then
if (header ~= "Strict-Transport-Security" or ssl) then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ location {{ url }} {% raw %}{{% endraw +%}
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Protocol $scheme;
proxy_set_header X-Forwarded-Host $http_host;
{% if url.startswith("/") +%}
proxy_set_header X-Forwarded-Prefix "{{ url }}";
{% endif %}
{% if buffering == "yes" +%}
proxy_buffering on;
{% else +%}
Expand Down
7 changes: 6 additions & 1 deletion tests/ui/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ if [ $? -ne 0 ] ; then
exit 1
fi
docker-compose -f docker-compose.test.yml up --abort-on-container-exit --exit-code-from ui-tests
ret=$?
if [ $ret -ne 0 ] ; then
docker-compose -f docker-compose.test.yml logs
echo "❌ Up failed"
fi

# Exit
exit $?
exit $ret

0 comments on commit bf9cd36

Please sign in to comment.