Skip to content

Commit 2e80872

Browse files
committed
Refactor Nginx configuration, update Docker setup, and upgrade dependencies
1 parent 208ffcc commit 2e80872

File tree

5 files changed

+117
-60
lines changed

5 files changed

+117
-60
lines changed

config.nginx

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,54 @@
1-
rtmp {
2-
server {
3-
listen 1935;
4-
chunk_size 4096;
5-
6-
application live {
7-
live on;
8-
record off;
9-
}
1+
server {
2+
listen 80;
3+
server_name _;
4+
5+
# --- General settings ---
6+
client_max_body_size 50M;
7+
sendfile on;
8+
tcp_nopush on;
9+
tcp_nodelay on;
10+
keepalive_timeout 65;
11+
12+
# --- WebSocket requires HTTP/1.1 ---
13+
proxy_http_version 1.1;
14+
15+
# ===============================
16+
# API & Frontend
17+
# ===============================
18+
location / {
19+
proxy_pass http://streamvision:3000;
20+
21+
proxy_set_header Host $host;
22+
proxy_set_header X-Real-IP $remote_addr;
23+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
24+
proxy_set_header X-Forwarded-Proto $scheme;
25+
26+
# Disable buffering for streaming
27+
proxy_buffering off;
28+
proxy_request_buffering off;
29+
}
30+
31+
# ===============================
32+
# WebSocket Streaming
33+
# ===============================
34+
location /ws {
35+
proxy_pass http://streamvision:3000;
36+
37+
# WebSocket headers
38+
proxy_set_header Upgrade $http_upgrade;
39+
proxy_set_header Connection "upgrade";
40+
41+
proxy_set_header Host $host;
42+
proxy_set_header X-Real-IP $remote_addr;
43+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
44+
proxy_set_header X-Forwarded-Proto $scheme;
45+
46+
# CRITICAL for video streaming
47+
proxy_buffering off;
48+
proxy_cache off;
49+
50+
# Prevent timeouts for long streams
51+
proxy_read_timeout 1h;
52+
proxy_send_timeout 1h;
1053
}
1154
}

docker-compose.yaml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
services:
22
streamvision:
3-
image: codebyamrit/streamvision:latest
3+
image: streamvision:latest
44
container_name: streamvision_app
5-
ports:
6-
- "3000:3000"
5+
expose:
6+
- "3000"
77
env_file:
88
- .env
99
restart: unless-stopped
10-
1110
tmpfs:
1211
- /tmp
13-
1412
security_opt:
1513
- no-new-privileges:true
16-
1714
logging:
1815
driver: "json-file"
1916
options:
2017
max-size: "10m"
2118
max-file: "5"
19+
20+
nginx:
21+
image: nginx:alpine
22+
container_name: streamvision_nginx
23+
ports:
24+
- "80:80"
25+
volumes:
26+
- ./config.nginx:/etc/nginx/conf.d/default.conf:ro
27+
depends_on:
28+
- streamvision
29+
restart: unless-stopped

package-lock.json

Lines changed: 41 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,27 @@
2828
"dotenv": "^17.2.3",
2929
"ejs": "^3.1.10",
3030
"encrypt": "^0.0.1",
31-
"express": "^5.1.0",
31+
"express": "^5.2.1",
3232
"express-validator": "^7.3.1",
3333
"ffprobe-static": "^3.1.0",
3434
"fluent-ffmpeg": "^2.1.3",
3535
"fs": "^0.0.1-security",
3636
"helmet": "^8.1.0",
37-
"jsonwebtoken": "^9.0.2",
37+
"jsonwebtoken": "^9.0.3",
3838
"jwa": "^2.0.1",
3939
"morgan": "^1.10.1",
40-
"mysql2": "^3.15.3",
40+
"mysql2": "^3.16.0",
4141
"nodemon": "^3.1.11",
4242
"path": "^0.12.7",
4343
"pg": "^8.16.3",
4444
"serve-favicon": "^2.5.1",
4545
"uuid": "^13.0.0",
46-
"winston": "^3.18.3",
46+
"winston": "^3.19.0",
4747
"winston-daily-rotate-file": "^5.0.0",
4848
"ws": "^8.18.3"
4949
},
5050
"devDependencies": {
5151
"flowbite": "^4.0.1",
52-
"tailwindcss": "^4.1.17"
52+
"tailwindcss": "^4.1.18"
5353
}
5454
}

utils/stream-instance.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,23 @@ class StreamInstance {
2121

2222
"-an",
2323
"-c:v", "libx264",
24-
"-preset", "ultrafast",
24+
"-preset", "veryfast",
2525
"-tune", "zerolatency",
2626
"-pix_fmt", "yuv420p",
2727
"-profile:v", "baseline",
2828
"-level", "3.1",
2929

30-
"-g", "30",
31-
"-keyint_min", "30",
30+
"-r", "25", // 👈 force FPS
31+
"-g", "60",
32+
"-keyint_min", "60",
3233
"-sc_threshold", "0",
3334

3435
"-movflags", "frag_keyframe+empty_moov+default_base_moof",
3536
"-f", "mp4",
3637
"pipe:1",
3738
]);
3839

40+
3941
this.ffmpeg.stdout.on("data", (chunk) => {
4042
for (const ws of this.clients) {
4143
if (ws.readyState === ws.OPEN) {

0 commit comments

Comments
 (0)