Files
3x-ui/docs/content/docs/fa/operations/reverse-proxy.mdx
T
MHSanaei d50c419e28 fix(web): read the client address from the proxy end of forwarded headers
getRemoteIp took a trusted proxy's X-Real-IP first, otherwise the leftmost
X-Forwarded-For entry. A proxy that forwards a client-sent X-Real-IP
unchanged (Caddy, HAProxy) or appends to X-Forwarded-For leaves both values
to the client. X-Forwarded-For is now read from the right, skipping trusted
proxies. X-Real-IP is believed only when it agrees with that hop or stands
alone, and a disagreement falls back to the proxy's own address.

The documented Caddyfile and the docs reverse-proxy generator now overwrite
X-Real-IP with the address Caddy saw.
2026-10-24 01:39:23 +02:00

54 lines
2.4 KiB
Plaintext

---
title: پراکسی معکوس
description: قرار دادن پنل و اشتراک 3x-ui پشت Nginx یا Caddy همراه با TLS از Let's Encrypt.
icon: Waypoints
---
پراکسی معکوس به شما امکان می‌دهد پنل و اشتراک را روی یک دامنه تمیز با HTTPS خودکار
ارائه دهید و پورت‌های واقعی را پشت پورت‌های 80/443 پنهان کنید. ترجیح می‌دهید خودِ
پنل مستقیماً TLS را مدیریت کند؟ به‌جای آن، گواهی را از طریق
[منوی SSL در `x-ui`](/docs/config/ssl-certificates) دریافت کنید.
## ساخت یک پیکربندی
<ReverseProxyGenerator />
<Callout type="info">
پنل برای به‌روزرسانی‌های زنده از WebSockets استفاده می‌کند، بنابراین پراکسی باید
هدرهای `Upgrade`/`Connection` را عبور دهد (خروجی Nginx بالا این کار را انجام
می‌دهد). Caddy ارتقاهای WebSocket را به‌صورت خودکار مدیریت می‌کند.
</Callout>
## Nginx + گواهی
با Nginx، گواهی را با `certbot` (یا `acme.sh`) دریافت کنید و در بلوک server به آن
ارجاع دهید:
```bash title="certbot"
certbot certonly --nginx -d panel.example.com
```
پس از نصب گواهی، Nginx را بارگذاری مجدد کنید و تمدید خودکار را راه‌اندازی کنید
(`certbot renew` به‌صورت پیش‌فرض روی یک تایمر اجرا می‌شود).
## Caddy
Caddy گواهی‌ها را برای شما دریافت و تمدید می‌کند — یک Caddyfile را به پنل اشاره
دهید و همه‌چیز کار می‌کند:
```text title="Caddyfile"
panel.example.com {
reverse_proxy 127.0.0.1:2053 {
header_up X-Real-IP {remote_host}
}
}
```
## نکته‌ها
- حتی پشت یک پراکسی هم **مسیر پایه وب** پنل را حفظ کنید؛ دفاع لایه‌به‌لایه.
- اگر TLS را در پراکسی مدیریت می‌کنید، ممکن است بخواهید `XUI_SKIP_HSTS=true` را روی
پنل تنظیم کنید — به [مرجع متغیرهای محیطی](/docs/reference/env-vars) مراجعه کنید.
- سرور [اشتراک](/docs/config/subscription) را هم پراکسی کنید تا محتوای آن نیز روی
HTTPS ارائه شود.