💬 Commented on "trustProxy: falseでIPベースのレートリミットが機能しないなどの問題がある": samunohito "> (うちがinternet -> cloudflare -> nginx -> Misskeyの構成なので検証したい) やってきました。 cloudflareを挟む場合、nginxの設定も必要そうです --- ① の実装 + のIPv6 ```ts const fastify = Fastify({ trustProxy: this.config.trustProxy ?? [ '10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', '127.0.0.1/32', '::1/128', 'fc00::/7' ], logger: false, }); ``` --- ②[Hubに記載されていたnginxの設定]() + cloudflareのドキュメントに[記載されていたサンプル]() + cloudflareが[公開](https://www.cloudflare.com/ips/)しているIP一覧 ```txt ... # Proxy to Node location / { proxy_pass http://127.0.0.1:3000; proxy_set_header Host $host; proxy_http_version 1.1; proxy_redirect off; # ---- 追記ここから ---- real_ip_header CF-Connecting-IP; real_ip_recursive on; set_real_ip_from 173.245.48.0/20; set_real_ip_from 103.21.244.0/22; set_real_ip_from 103.22.200.0/22; set_real_ip_from 103.31.4.0/22; set_real_ip_from 141.101.64.0/18; set_real_ip_from 108.162.192.0/18; set_real_ip_from 190.93.240.0/20; set_real_ip_from 188.114.96.0/20; set_real_ip_from 197.234.240.0/22; set_real_ip_from 198.41.128.0/17; set_real_ip_from 162.158.0.0/15; set_real_ip_from 104.16.0.0/13; set_real_ip_from 104.24.0.0/14; set_real_ip_from 172.64.0.0/13; set_real_ip_from 131.0.72.0/22; set_real_ip_from 2400:cb00::/32; set_real_ip_from 2606:4700::/32; set_real_ip_from 2803:f800::/32; set_real_ip_from 2405:b500::/32; set_real_ip_from 2405:8100::/32; set_real_ip_from 2a06:98c0::/29; set_real_ip_from 2c0f:f248::/32; # ---- 追記ここまで ---- # If it's behind another reverse proxy or CDN, remove the following. 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 https; ... ``` --- 実際にログイン履歴で確認してみたもの↓ ![Image](https://github.com/user-attachments/assets/c6369d05-4d38-4078-b0a4-b01a5e05bb48) - 下段:configもソースも何も対応してない(2025.12.0の素の状態に近い) - 中段:①だけ施した状態。cloudflareが公開しているIP帯の中にあるものだった(一応伏せた) - 上段:①と②を施した状態。自宅のIPv6が記録されている"
💬 Commented on "enhance(backend/test): Migrate tests to vitest 【実験中】": kakkokari-gtyih "unit test 通った あとは e2e"