diff --git a/server/server.js b/server/server.js index 2d3f37ee..0c08da07 100644 --- a/server/server.js +++ b/server/server.js @@ -164,12 +164,20 @@ let needSetup = false; // Entry Page app.get("/", async (request, response) => { - log.debug("entry", `Request Domain: ${request.hostname}`); + let hostname = request.hostname; + if (await setting("trustProxy")) { + const proxy = request.headers["x-forwarded-host"]; + if (proxy) { + hostname = proxy; + } + } - if (request.hostname in StatusPage.domainMappingList) { + log.debug("entry", `Request Domain: ${hostname}`); + + if (hostname in StatusPage.domainMappingList) { log.debug("entry", "This is a status page domain"); - let slug = StatusPage.domainMappingList[request.hostname]; + let slug = StatusPage.domainMappingList[hostname]; await StatusPage.handleStatusPageResponse(response, server.indexHTML, slug); } else if (exports.entryPage && exports.entryPage.startsWith("statusPage-")) { diff --git a/server/uptime-kuma-server.js b/server/uptime-kuma-server.js index e93e2b78..3362f72c 100644 --- a/server/uptime-kuma-server.js +++ b/server/uptime-kuma-server.js @@ -50,7 +50,6 @@ class UptimeKumaServer { log.info("server", "Creating express and socket.io instance"); this.app = express(); - if (sslKey && sslCert) { log.info("server", "Server Type: HTTPS"); this.httpServer = https.createServer({ diff --git a/src/components/settings/ReverseProxy.vue b/src/components/settings/ReverseProxy.vue index 616b0996..0fab7629 100644 --- a/src/components/settings/ReverseProxy.vue +++ b/src/components/settings/ReverseProxy.vue @@ -91,6 +91,51 @@ {{ $t("For example: nginx, Apache and Traefik.") }}
{{ $t("Please read") }} https://github.com/louislam/uptime-kuma/wiki/Reverse-Proxy. + +

{{ $t("HTTP Headers") }}

+
+ +
+ + +
+
+ + +
+ +
+ {{ $t("trustProxyDescription") }} +
+
+ +
+ +
@@ -113,6 +158,12 @@ export default { settings() { return this.$parent.$parent.$parent.settings; }, + saveSettings() { + return this.$parent.$parent.$parent.saveSettings; + }, + settingsLoaded() { + return this.$parent.$parent.$parent.settingsLoaded; + }, }, watch: { diff --git a/src/languages/en.js b/src/languages/en.js index e9b5e2d3..352a63f6 100644 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -453,6 +453,8 @@ export default { "Message:": "Message:", "Don't know how to get the token? Please read the guide:": "Don't know how to get the token? Please read the guide:", "The current connection may be lost if you are currently connecting via Cloudflare Tunnel. Are you sure want to stop it? Type your current password to confirm it.": "The current connection may be lost if you are currently connecting via Cloudflare Tunnel. Are you sure want to stop it? Type your current password to confirm it.", + "HTTP Headers": "HTTP Headers", + "Trust Proxy": "Trust Proxy", "Other Software": "Other Software", "For example: nginx, Apache and Traefik.": "For example: nginx, Apache and Traefik.", "Please read": "Please read", @@ -536,5 +538,6 @@ export default { "Domain": "Domain", "Workstation": "Workstation", disableCloudflaredNoAuthMsg: "You are in No Auth mode, password is not require.", + trustProxyDescription: "Trust 'X-Forwarded-*' headers. If you want to get the correct client IP and your Uptime Kuma is behind such as Nginx or Apache, you should enable this.", wayToGetLineNotifyToken: "You can get an access token from {0}", }; diff --git a/src/pages/Settings.vue b/src/pages/Settings.vue index 03eb09e9..e1013789 100644 --- a/src/pages/Settings.vue +++ b/src/pages/Settings.vue @@ -153,6 +153,10 @@ export default { this.settings.tlsExpiryNotifyDays = [ 7, 14, 21 ]; } + if (this.settings.trustProxy === undefined) { + this.settings.trustProxy = false; + } + this.settingsLoaded = true; }); },