103 lines
3.5 KiB
Plaintext
103 lines
3.5 KiB
Plaintext
# Add this to your nginx server block configuration
|
|
# Usually located in /etc/nginx/sites-available/your-site or /etc/nginx/nginx.conf
|
|
|
|
server {
|
|
listen 80; # or 443 for SSL
|
|
server_name yourserver.com; # Replace with your domain
|
|
|
|
# Your existing web application routes
|
|
location / {
|
|
# Your existing configuration
|
|
root /var/www/html;
|
|
index index.html index.htm;
|
|
try_files $uri $uri/ =404;
|
|
}
|
|
|
|
# WebSocket route for WhisperLive
|
|
location /whisper-ws {
|
|
# Proxy to localhost port where your remote port forwarding is set up
|
|
proxy_pass http://localhost:9090; # Replace 9090 with your forwarded port
|
|
|
|
# WebSocket specific headers
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header 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 $scheme;
|
|
|
|
# WebSocket timeout settings
|
|
proxy_connect_timeout 60s;
|
|
proxy_send_timeout 60s;
|
|
proxy_read_timeout 60s;
|
|
|
|
# Buffer settings for real-time streaming
|
|
proxy_buffering off;
|
|
proxy_request_buffering off;
|
|
|
|
# Optional: Add CORS headers if needed
|
|
add_header Access-Control-Allow-Origin *;
|
|
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
|
|
add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization";
|
|
}
|
|
|
|
# Optional: Handle preflight requests for CORS
|
|
location = /whisper-ws {
|
|
if ($request_method = OPTIONS) {
|
|
add_header Access-Control-Allow-Origin *;
|
|
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
|
|
add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization";
|
|
add_header Access-Control-Max-Age 86400;
|
|
add_header Content-Type "text/plain charset=UTF-8";
|
|
add_header Content-Length 0;
|
|
return 204;
|
|
}
|
|
}
|
|
}
|
|
|
|
# If you're using SSL (recommended), add this SSL configuration
|
|
# server {
|
|
# listen 443 ssl http2;
|
|
# server_name yourserver.com;
|
|
#
|
|
# ssl_certificate /path/to/your/cert.pem;
|
|
# ssl_certificate_key /path/to/your/private.key;
|
|
#
|
|
# # SSL configuration
|
|
# ssl_protocols TLSv1.2 TLSv1.3;
|
|
# ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384;
|
|
# ssl_prefer_server_ciphers off;
|
|
#
|
|
# # Same location blocks as above
|
|
# location / {
|
|
# root /var/www/html;
|
|
# index index.html index.htm;
|
|
# try_files $uri $uri/ =404;
|
|
# }
|
|
#
|
|
# location /whisper-ws {
|
|
# proxy_pass http://localhost:9090;
|
|
# proxy_http_version 1.1;
|
|
# proxy_set_header Upgrade $http_upgrade;
|
|
# proxy_set_header 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 $scheme;
|
|
#
|
|
# proxy_connect_timeout 60s;
|
|
# proxy_send_timeout 60s;
|
|
# proxy_read_timeout 60s;
|
|
#
|
|
# proxy_buffering off;
|
|
# proxy_request_buffering off;
|
|
# }
|
|
# }
|
|
|
|
# Redirect HTTP to HTTPS if using SSL
|
|
# server {
|
|
# listen 80;
|
|
# server_name yourserver.com;
|
|
# return 301 https://$server_name$request_uri;
|
|
# } |