core: handle reverse_proxy chains

This commit is contained in:
undefined committed 2022-09-05 23:53:48 +08:00
1 parent c58c0d8465
commit 3f337e41c3
5 files changed
+8 -7

No files matched your search

+2 -3
View File
@@ -1,7 +1,6 @@
hydro.ac {
reverse_proxy http://localhost:8888 {
header_up x-real-ip {remote_host}
# caddy now add x-forwarded-host automatically.
# header_up x-forwarded-host {hostport}
header_up x-forwarded-for {remote_host}
header_up x-forwarded-host {hostport}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "3.16.10",
"version": "3.16.11",
"bin": "bin/hydrooj.js",
"main": "src/loader",
"module": "src/loader",
+3 -1
View File
@@ -18,7 +18,9 @@ export default async (ctx, next) => {
const { domainId, domainInfo } = ctx;
const isWebsocket = ctx.request.headers.upgrade === 'websocket';
const [xff, xhost] = system.getMany(['server.xff', 'server.xhost']);
const ip = ctx.request.headers[xff?.toLowerCase() || ''] as string || ctx.request.ip;
// ignore reverse_proxy chains
const ipHeader = ctx.request.headers[xff?.toLowerCase() || ''];
const ip = (typeof ipHeader === 'string' ? ipHeader : ipHeader[0] || ctx.request.ip).split(',')[0].trim();
const host = ctx.request.headers[xhost?.toLowerCase() || ''] as string || ctx.request.host;
const request: HydroRequest = {
method: ctx.request.method.toLowerCase(),
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@hydrooj/ui-default",
"version": "4.39.24",
"version": "4.39.25",
"author": "undefined <i@undefined.moe>",
"license": "AGPL-3.0",
"main": "hydro.js",
@@ -17,7 +17,7 @@
<link rel="icon" type="image/png" href="{{ UiContext.cdn_prefix }}android-chrome-192x192.png" sizes="192x192">
<link rel="icon" type="image/png" href="{{ UiContext.cdn_prefix }}favicon-96x96.png" sizes="96x96">
<link rel="icon" type="image/png" href="{{ UiContext.cdn_prefix }}favicon-16x16.png" sizes="16x16">
<link rel="canonical" href="{{ model.system.get('server.url') }}{{ handler.ctx.request.url.substring(1) }}">
{% if handler.ctx.request.url %}<link rel="canonical" href="{{ model.system.get('server.url') }}{{ handler.ctx.request.url.substring(1) }}">{% endif %}
<meta name="theme-color" content="#56758f">
{% block ogp %}
<meta property="og:site_name" content="{{ (handler.domain|default({ui:[]})).ui.name|default(model.system.get('server.name')) }}" />