I try to make little youtube. I have two servers.
- Backend server Ubuntu16. Server has application + mp4 files.
Django + uWSGI +
NGINX
user www-data;
worker_processes auto;
pid /etc/nginx/logs/nginx.pid;
events {
worker_connections 1024;
multi_accept on;
}
http {
upstream django {
server 127.0.0.1:8000;
}
server {
listen 80;
server_name XXX.XXX.XXX.191;
charset utf-8;
gzip on;
gzip_static on;
gzip_comp_level 5;
gzip_min_length 1024;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
if_modified_since off;
add_header Accept-Ranges bytes;
location /static/ {
root /home/tube;
}
location / {
uwsgi_pass django;
include uwsgi_params;
}
}
}
When I load page with video from browser using http://www.backend/, I see: 1.mp4 - answer 206 - chunk 2mb. After I click to play, the video starts to play chunk by chunk with answer 206. Seems to be correct. This is backend server (it has public access )
- Frontend server Ubuntu16. NGINX as reverse proxy.
user www-data; worker_processes auto; pid /etc/nginx/logs/nginx.pid; events {worker_connections 1024;} http { include mime.types; default_type application/octet-stream; server { listen 80; server_name XXX.XXX.XXX.92; proxy_http_version 1.1; proxy_pass_request_headers on; 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_set_header Range $http_range; proxy_set_header If-Range $http_if_range; proxy_no_cache $http_range $http_if_range; location / { proxy_pass http://XXX.XXX.XXX.191/; } } }
When I load the same page with video from browser using http://www.frontend/ I see: 1.mp4 - answer 200 - preload starts until full lenght of video (~150mb), instead 2mb chunk. After preload finished, I can click play and video starts streaming, loading mp4 again (answer 200)
I want that frontend server streaming videos correctly. First chunk 2-4mb after I load html, the rest chunks after i click play.