mirror of
https://github.com/619dev/Paperphone-plus.git
synced 2026-09-03 07:18:05 +08:00
135 lines
4.7 KiB
Plaintext
135 lines
4.7 KiB
Plaintext
# PaperPhonePlus production reverse proxy
|
|
#
|
|
# Replace api.example.com and meeting.example.com before enabling this file.
|
|
# Expected local services:
|
|
# PaperPhonePlus server http://127.0.0.1:3000
|
|
# LiveKit API/WebSocket http://127.0.0.1:7880
|
|
#
|
|
# IMPORTANT: Nginx only proxies HTTPS/WebSocket signaling here. LiveKit media
|
|
# ports must be opened directly in the host/cloud firewall:
|
|
# TCP 7881 (ICE/TCP fallback)
|
|
# UDP 7882 (preferred WebRTC media transport)
|
|
|
|
map $http_upgrade $connection_upgrade {
|
|
default upgrade;
|
|
'' close;
|
|
}
|
|
|
|
# Redirect both public domains to HTTPS. Keep the ACME path available when
|
|
# using certbot --webroot.
|
|
server {
|
|
listen 80;
|
|
listen [::]:80;
|
|
server_name api.example.com meeting.example.com;
|
|
|
|
location ^~ /.well-known/acme-challenge/ {
|
|
root /var/www/certbot;
|
|
default_type text/plain;
|
|
}
|
|
|
|
location / {
|
|
return 301 https://$host$request_uri;
|
|
}
|
|
}
|
|
|
|
# ── PaperPhonePlus Rust server ──────────────────────────────────────────
|
|
server {
|
|
listen 443 ssl http2;
|
|
listen [::]:443 ssl http2;
|
|
server_name api.example.com;
|
|
|
|
ssl_certificate /etc/letsencrypt/live/api.example.com/fullchain.pem;
|
|
ssl_certificate_key /etc/letsencrypt/live/api.example.com/privkey.pem;
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|
ssl_session_cache shared:PaperPhoneTLS:20m;
|
|
ssl_session_timeout 1d;
|
|
ssl_session_tickets off;
|
|
|
|
client_max_body_size 512m;
|
|
client_body_timeout 600s;
|
|
send_timeout 600s;
|
|
|
|
add_header X-Content-Type-Options nosniff always;
|
|
add_header Referrer-Policy strict-origin-when-cross-origin always;
|
|
|
|
# REST API. Keep proxy_pass without a trailing slash so Axum receives the
|
|
# original /api/... path unchanged.
|
|
location /api/ {
|
|
proxy_pass http://127.0.0.1:3000;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Host $host;
|
|
proxy_set_header X-Forwarded-Proto https;
|
|
proxy_connect_timeout 10s;
|
|
proxy_read_timeout 600s;
|
|
proxy_send_timeout 600s;
|
|
proxy_request_buffering off;
|
|
}
|
|
|
|
# Downloads, admin panel and health endpoint.
|
|
location / {
|
|
proxy_pass http://127.0.0.1:3000;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Host $host;
|
|
proxy_set_header X-Forwarded-Proto https;
|
|
proxy_connect_timeout 10s;
|
|
proxy_read_timeout 600s;
|
|
proxy_send_timeout 600s;
|
|
proxy_request_buffering off;
|
|
}
|
|
|
|
# IM signaling WebSocket. This more-specific location overrides the
|
|
# general proxy timeout and keeps long-lived sessions open.
|
|
location = /ws {
|
|
proxy_pass http://127.0.0.1:3000;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection $connection_upgrade;
|
|
proxy_set_header Host $host;
|
|
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;
|
|
proxy_buffering off;
|
|
proxy_read_timeout 1d;
|
|
proxy_send_timeout 1d;
|
|
}
|
|
}
|
|
|
|
# ── LiveKit SFU signaling/API ───────────────────────────────────────────
|
|
# Set LIVEKIT_URL=wss://meeting.example.com on the PaperPhonePlus server.
|
|
server {
|
|
listen 443 ssl http2;
|
|
listen [::]:443 ssl http2;
|
|
server_name meeting.example.com;
|
|
|
|
ssl_certificate /etc/letsencrypt/live/meeting.example.com/fullchain.pem;
|
|
ssl_certificate_key /etc/letsencrypt/live/meeting.example.com/privkey.pem;
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|
ssl_session_cache shared:PaperPhoneTLS:20m;
|
|
ssl_session_timeout 1d;
|
|
ssl_session_tickets off;
|
|
|
|
add_header X-Content-Type-Options nosniff always;
|
|
|
|
location / {
|
|
proxy_pass http://127.0.0.1:7880;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection $connection_upgrade;
|
|
proxy_set_header Host $host;
|
|
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;
|
|
proxy_buffering off;
|
|
proxy_request_buffering off;
|
|
proxy_connect_timeout 10s;
|
|
proxy_read_timeout 1d;
|
|
proxy_send_timeout 1d;
|
|
}
|
|
}
|