Reverse Proxy
วาง Fluxheim ไว้หน้า application server ของคุณ Fluxheim จะจัดการ TLS, header, limit และการเลือก upstream
Basic proxy
[[vhosts]]
name = "app"
hosts = ["app.example.com"]
[[vhosts.routes]]
path_prefix = "/"
action = "proxy"
upstreams = ["127.0.0.1:3000"]
ตัวเลือก route
| ฟีเจอร์ | ใช้เมื่อ |
|---|---|
path_exact | URL หนึ่งรายการต้องมีเส้นทางที่ชัดเจน |
path_prefix | A whole URL subtree goes to one แบ็กเอนด์. |
strip_prefix | The แบ็กเอนด์ should not see the สาธารณะ prefix. |
rewrite_prefix | The แบ็กเอนด์ expects a different internal prefix. |
methods | เส้นทางควรยอมรับเฉพาะวิธี HTTP ที่เลือกเท่านั้น |
ตัวอย่างการเขียนเส้นทางใหม่
[[vhosts.routes]]
name = "api"
path_prefix = "/api/"
strip_prefix = "/api/"
rewrite_prefix = "/internal/"
[vhosts.routes.proxy]
upstreams = ["10.0.0.20:8080"]
connect_timeout_secs = 5
read_timeout_secs = 30
send_timeout_secs = 30
CORS สำหรับแอปเบราว์เซอร์
เปิดใช้งาน CORS เฉพาะเมื่อแอปพลิเคชันเบราว์เซอร์บนต้นทางที่รู้จักต้องเรียกใช้เส้นทางนี้
[headers.cors]
enabled = true
allow_origins = ["https://app.example.com"]
allow_methods = ["GET", "HEAD", "POST"]
allow_headers = ["authorization", "content-type"]
allow_credentials = true
max_age_secs = 600
- Fluxheim ตอบคำขอ preflight ที่ถูกต้องภายในเครื่อง ส่วน preflight ที่ถูกปฏิเสธจะส่งคืน
403โดยไม่ส่งถึงแอปพลิเคชัน - อย่ารวมต้นกำเนิดไวด์การ์ดเข้ากับข้อมูลรับรอง
- CORS ไม่ใช่การรับรองความถูกต้อง การอนุญาต หรือการป้องกัน CSRF
หมายเหตุสำหรับโปรดักชัน
- เก็บแอปพลิเคชันไว้บน loopback หรือเครือข่ายส่วนตัว
- ตั้งขนาด request body ก่อนเปิดให้ upload
- Use trusted proxy settings only for networks you control.
- Prefer explicit routes over one large fallback when different paths need different ปลอดภัยty rules.