~johanvandegriff/live.johanv.xyz

live.johanv.xyz/nginx.conf -rw-r--r-- 2.5 KiB
c59722bdJohan Vandegriff ignored whispers 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#user nginx;

# I'll explain why we only have 1 worker process later
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

include /usr/share/nginx/modules/*.conf;

events {
    use epoll;
    worker_connections 1024;
}

http {
    log_format main '$remote_addr - $remote_user [$time_local] "$request" '
                    '$status $body_bytes_sent "$http_referer" '
                    '"$http_user_agent" "$http_x_forwarded_for" $request_time';
    access_log /var/log/nginx/access.log main;
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    server {
        listen 80 default_server;
        server_name _;
        root /var/www;
        expires -1d;

        location ~ ^/live/.+\.ts$ {
            # MPEG-TS segments can be cached upstream indefinitely
            expires max;
        }
    }

    #server {
    #    listen 5005;
    #    location /auth {
    #        if ($args ~ psk=secret) {
    #            return 201;
    #        }
    #        return 401;
    #    }
    #}

}

rtmp {
    server {
        listen 1935;

        application app {
            live on;

            # Don't allow RTMP playback
            deny play all;

            # Forward the stream to my dlive, twitch, and youtube
            #push rtmp://stream.dlive.tv/live/<PUT YOUR STREAM KEY HERE>;
            #push rtmp://live.twitch.tv/app/<PUT YOUR STREAM KEY HERE>;
            #push rtmp://a.rtmp.youtube.com/live2/<PUT YOUR STREAM KEY HERE>;
            include /srv/*.conf;

            # When stream starts, authenticate
            #on_publish http://localhost:5005/auth;

            # only allow streaming from localhost
            # the problem is that everything comes through the dokku nginx proxy, so the source ip is always 172.17.0.1
            # because of this, we have to keep port 1935 closed and broadcast only with hls, and tunnel in with ssh:
            # ssh -NL 1935:localhost:1935 user@server  #<--- on local machine where OBS is running
            # OBS Settings:
            # server: rtmp://localhost/app/
            # stream key: stream
            allow publish 127.0.0.1;
            allow publish 172.17.0.1;
            deny publish all;

            # Package streams as HLS
            hls on;
            hls_path /var/www/live;
            hls_nested on;
            hls_fragment_naming system;
            #hls_datetime system;
        }
    }
}