Add backward compatibility for /ingestor route in Nginx and ProbeIngest; update Probe configuration for new URL structure

This commit is contained in:
Simon Larsen 2024-11-21 17:53:35 +00:00
parent 815ae7161d
commit 4fc2029a61
No known key found for this signature in database
GPG Key ID: 96C5DCA24769DBCA
3 changed files with 26 additions and 9 deletions

View File

@ -563,6 +563,24 @@ server {
client_max_body_size 50M;
}
# For backward compatibility with probes that are already deployed
location /ingestor {
# This is for nginx not to crash when service is not available.
resolver 127.0.0.1 valid=30s;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# enable WebSockets (for ws://sockjs not connected error in the accounts source: https://stackoverflow.com/questions/41381444/websocket-connection-failed-error-during-websocket-handshake-unexpected-respon)
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://probe-ingest;
client_max_body_size 50M;
}
location /server-monitor {
# This is for nginx not to crash when service is not available.
resolver 127.0.0.1 valid=30s;

View File

@ -18,7 +18,9 @@ if (
!PROBE_INGEST_URL.toString().endsWith("probe-ingest") &&
!PROBE_INGEST_URL.toString().endsWith("probe-ingest/")
) {
PROBE_INGEST_URL = URL.fromString(PROBE_INGEST_URL.addRoute("/probe-ingest").toString());
PROBE_INGEST_URL = URL.fromString(
PROBE_INGEST_URL.addRoute("/probe-ingest").toString(),
);
}
export const PROBE_NAME: string | null = process.env["PROBE_NAME"] || null;

View File

@ -1,6 +1,4 @@
import IncomingRequestAPI from "../IncomingRequestIngest/API/IncomingRequest";
import MonitorAPI from "./API/Monitor";
import OTelIngestAPI from "./API/OTelIngest";
import ProbeIngest from "./API/Probe";
import RegisterAPI from "./API/Register";
import ServerMonitorAPI from "./API/ServerMonitor";
@ -20,12 +18,11 @@ const app: ExpressApplication = Express.getExpressApp();
const APP_NAME: string = "probe-ingest";
app.use([`/${APP_NAME}`, "/"], RegisterAPI);
app.use([`/${APP_NAME}`, "/"], MonitorAPI);
app.use([`/${APP_NAME}`, "/"], ProbeIngest);
app.use([`/${APP_NAME}`, "/"], IncomingRequestAPI);
app.use([`/${APP_NAME}`, "/"], OTelIngestAPI);
app.use([`/${APP_NAME}`, "/"], ServerMonitorAPI);
// "/ingestor" is used here for backward compatibility because probes are already deployed with this path in client environments.
app.use([`/${APP_NAME}`, "/ingestor", "/"], RegisterAPI);
app.use([`/${APP_NAME}`, "/ingestor", "/"], MonitorAPI);
app.use([`/${APP_NAME}`, "/ingestor", "/"], ProbeIngest);
app.use([`/${APP_NAME}`, "/ingestor", "/"], ServerMonitorAPI);
const init: PromiseVoidFunction = async (): Promise<void> => {
try {