Skip to content

Commit

Permalink
Add backward compatibility for /ingestor route in Nginx and ProbeInge…
Browse files Browse the repository at this point in the history
…st; update Probe configuration for new URL structure
  • Loading branch information
simlarsen committed Nov 21, 2024
1 parent 815ae71 commit 4fc2029
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
18 changes: 18 additions & 0 deletions Nginx/default.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion Probe/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 5 additions & 8 deletions ProbeIngest/Index.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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 {
Expand Down

0 comments on commit 4fc2029

Please sign in to comment.