Permalink
Browse files

Merge pull request #737 from amazeeio/736-hotfix-lua-local

#736 Hotfix: Check if env variables exist before using them
  • Loading branch information...
Schnitzel committed Nov 8, 2018
2 parents 1fc2b16 + 1d8e720 commit de76acc55db714cbeeda7575d37a184909065d79
Showing with 5 additions and 2 deletions.
  1. +5 −2 images/nginx/helpers/x-robots-header-development.conf
@@ -2,11 +2,14 @@
header_filter_by_lua_block {
-- escape characters in the hostname
host = string.gsub(ngx.var.host, "%p", "%%%1")
-- check to see if we are a development environment
if string.match (os.getenv("LAGOON_ENVIRONMENT_TYPE"), 'development') then
if (os.getenv("LAGOON_ENVIRONMENT_TYPE") and string.match(os.getenv("LAGOON_ENVIRONMENT_TYPE"), 'development')) then
ngx.header["X-Robots-Tag"] = 'noindex, nofollow';
end
-- check hostname against autogenerated routes
elseif string.match (os.getenv("LAGOON_AUTOGENERATED_ROUTES"),host) then
if (os.getenv("LAGOON_AUTOGENERATED_ROUTES") and string.match(os.getenv("LAGOON_AUTOGENERATED_ROUTES"), host)) then
ngx.header["X-Robots-Tag"] = 'noindex, nofollow';
end
}

0 comments on commit de76acc

Please sign in to comment.