Skip to content
Snippets Groups Projects
Unverified Commit 8ebe3e4e authored by Yuriy Galanter's avatar Yuriy Galanter Committed by GitHub
Browse files

Don't set Site URL on requests from ELB HealthChecker (#12996)

* Fix for AWS ELB issue

When Metabase is deployed to AWS behind ELB the very first call to it is made by ELB health check. Out of `origin`, `x-forwarded-host`,  `host` in this case only `host` is populated and it is populated with internal private IP. This causes `site-url` to be populated with URL with private IP in it. The fix is checks for caller user agent and if it contains "HealthChecker" - does not set `site-url` at this time

* Added missing user-agent

* Added check for nil user-agent
parent abbc9e7d
Branches
Tags
No related merge requests found
......@@ -40,10 +40,10 @@
;;
;; Effectively the very first API request that gets sent to us (usually some sort of setup request) ends up setting
;; the (initial) value of `site-url`
(defn- maybe-set-site-url* [{{:strs [origin x-forwarded-host host] :as headers} :headers, :as request}]
(defn- maybe-set-site-url* [{{:strs [origin x-forwarded-host host user-agent] :as headers} :headers, :as request}]
(when (and (mdb/db-is-setup?)
(not (public-settings/site-url))
api/*current-user*)
api/*current-user* (or (nil? user-agent) ((complement clojure.string/includes?) user-agent "HealthChecker"))); Not setting URL if it's a healthcheck by ELB
(when-let [site-url (or origin x-forwarded-host host)]
(log/info (trs "Setting Metabase site URL to {0}" site-url))
(try
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment