mirror of
https://github.com/mastodon/mastodon.git
synced 2025-03-12 00:45:22 +00:00
Streaming: fix trust proxy configuration
The previous one that used the default of 'loopback,uniqueclient' threw a server crashing error
This commit is contained in:
parent
a22df7db27
commit
b595825e5a
|
@ -9,6 +9,7 @@ import cors from 'cors';
|
|||
import dotenv from 'dotenv';
|
||||
import express from 'express';
|
||||
import { JSDOM } from 'jsdom';
|
||||
import proxyaddr from 'proxy-addr';
|
||||
import { WebSocketServer } from 'ws';
|
||||
|
||||
import * as Database from './database.js';
|
||||
|
@ -145,8 +146,13 @@ const startServer = async () => {
|
|||
});
|
||||
|
||||
const app = express();
|
||||
const trustProxy = proxyaddr.compile(
|
||||
process.env.TRUSTED_PROXY_IP ?
|
||||
process.env.TRUSTED_PROXY_IP.split(/(?:\s*,\s*|\s+)/) :
|
||||
['loopback', 'uniquelocal']
|
||||
);
|
||||
|
||||
app.set('trust proxy', process.env.TRUSTED_PROXY_IP ? process.env.TRUSTED_PROXY_IP.split(/(?:\s*,\s*|\s+)/) : 'loopback,uniquelocal');
|
||||
app.set('trust proxy', trustProxy);
|
||||
|
||||
app.use(httpLogger);
|
||||
app.use(cors());
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
"pino": "^9.0.0",
|
||||
"pino-http": "^10.0.0",
|
||||
"prom-client": "^15.0.0",
|
||||
"proxy-addr": "~2.0.7",
|
||||
"uuid": "^11.0.0",
|
||||
"ws": "^8.12.1"
|
||||
},
|
||||
|
@ -34,6 +35,7 @@
|
|||
"@types/cors": "^2.8.16",
|
||||
"@types/express": "^4.17.17",
|
||||
"@types/pg": "^8.6.6",
|
||||
"@types/proxy-addr": "^2.0.3",
|
||||
"@types/uuid": "^10.0.0",
|
||||
"@types/ws": "^8.5.9",
|
||||
"eslint-define-config": "^2.0.0",
|
||||
|
|
11
yarn.lock
11
yarn.lock
|
@ -3010,6 +3010,7 @@ __metadata:
|
|||
"@types/cors": "npm:^2.8.16"
|
||||
"@types/express": "npm:^4.17.17"
|
||||
"@types/pg": "npm:^8.6.6"
|
||||
"@types/proxy-addr": "npm:^2.0.3"
|
||||
"@types/uuid": "npm:^10.0.0"
|
||||
"@types/ws": "npm:^8.5.9"
|
||||
bufferutil: "npm:^4.0.7"
|
||||
|
@ -3025,6 +3026,7 @@ __metadata:
|
|||
pino-http: "npm:^10.0.0"
|
||||
pino-pretty: "npm:^11.0.0"
|
||||
prom-client: "npm:^15.0.0"
|
||||
proxy-addr: "npm:~2.0.7"
|
||||
typescript: "npm:^5.0.4"
|
||||
utf-8-validate: "npm:^6.0.3"
|
||||
uuid: "npm:^11.0.0"
|
||||
|
@ -3887,6 +3889,15 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@types/proxy-addr@npm:^2.0.3":
|
||||
version: 2.0.3
|
||||
resolution: "@types/proxy-addr@npm:2.0.3"
|
||||
dependencies:
|
||||
"@types/node": "npm:*"
|
||||
checksum: 10c0/680f5eeaf434461daf856d694fd6b228c9850f736f377b8fc1d373ba282feca25bc642eeed93f3a9511d9406a9b93014b94c4d7cb8488646482ca0610d931e30
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@types/punycode@npm:^2.1.0":
|
||||
version: 2.1.4
|
||||
resolution: "@types/punycode@npm:2.1.4"
|
||||
|
|
Loading…
Reference in New Issue
Block a user