mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-09 23:24:07 -08:00
Use x-forwarded-host only when trustProxy is true
This commit is contained in:
parent
6ce012c9a1
commit
3fa5dfc873
|
@ -164,12 +164,20 @@ let needSetup = false;
|
||||||
|
|
||||||
// Entry Page
|
// Entry Page
|
||||||
app.get("/", async (request, response) => {
|
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");
|
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);
|
await StatusPage.handleStatusPageResponse(response, server.indexHTML, slug);
|
||||||
|
|
||||||
} else if (exports.entryPage && exports.entryPage.startsWith("statusPage-")) {
|
} else if (exports.entryPage && exports.entryPage.startsWith("statusPage-")) {
|
||||||
|
|
|
@ -49,8 +49,6 @@ class UptimeKumaServer {
|
||||||
|
|
||||||
log.info("server", "Creating express and socket.io instance");
|
log.info("server", "Creating express and socket.io instance");
|
||||||
this.app = express();
|
this.app = express();
|
||||||
this.app.enable("trust proxy");
|
|
||||||
|
|
||||||
if (sslKey && sslCert) {
|
if (sslKey && sslCert) {
|
||||||
log.info("server", "Server Type: HTTPS");
|
log.info("server", "Server Type: HTTPS");
|
||||||
this.httpServer = https.createServer({
|
this.httpServer = https.createServer({
|
||||||
|
|
Loading…
Reference in a new issue