From ec51c2ed6be15ceda8c0ee37f8b17a5cff81975b Mon Sep 17 00:00:00 2001 From: posimai Date: Mon, 20 Apr 2026 13:34:22 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20trust=20proxy=20=E3=82=92=E8=A8=AD?= =?UTF-8?q?=E5=AE=9A=E3=81=97=E3=81=A6=20req.ip=20=E3=82=92=E6=AD=A3?= =?UTF-8?q?=E3=81=97=E3=81=8F=E3=82=AF=E3=83=A9=E3=82=A4=E3=82=A2=E3=83=B3?= =?UTF-8?q?=E3=83=88IP=E3=81=AB=E8=A7=A3=E6=B1=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit nginx リバースプロキシ背後では req.ip がプロキシの内部 IP になる問題を修正。 app.set('trust proxy', 1) で X-Forwarded-For を信頼し、IP ベースの レート制限(together/ponshu)が実際のクライアント IP で動作するようにする。 Co-Authored-By: Claude Sonnet 4.6 --- server.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server.js b/server.js index 98a67107..14697ff6 100644 --- a/server.js +++ b/server.js @@ -116,6 +116,8 @@ async function createSessionJWT(userId) { } const app = express(); +// nginx リバースプロキシ背後のため X-Forwarded-For を信頼して req.ip を正しく解決 +app.set('trust proxy', 1); // Stripe Webhook は raw body が必要なため、webhook パスのみ json パースをスキップ app.use((req, res, next) => { if (req.path === '/brain/api/stripe/webhook' || req.path === '/api/stripe/webhook') {