|
2 | 2 | <feed xmlns="http://www.w3.org/2005/Atom"> |
3 | 3 | <id>https://newdy.cf</id> |
4 | 4 | <title>Gridea</title> |
5 | | - <updated>2020-02-19T04:25:37.307Z</updated> |
| 5 | + <updated>2020-02-19T04:31:18.215Z</updated> |
6 | 6 | <generator>https://github.com/jpmonette/feed</generator> |
7 | 7 | <link rel="alternate" href="https://newdy.cf"/> |
8 | 8 | <link rel="self" href="https://newdy.cf/atom.xml"/> |
9 | 9 | <subtitle>温故而知新</subtitle> |
10 | 10 | <logo>https://newdy.cf/images/avatar.png</logo> |
11 | 11 | <icon>https://newdy.cf/favicon.ico</icon> |
12 | 12 | <rights>All rights reserved 2020, Gridea</rights> |
| 13 | + <entry> |
| 14 | + <title type="html"><![CDATA[Windows10下nginx的rtmp服务器搭建]]></title> |
| 15 | + <id>https://newdy.cf/post/windows10-xia-nginx-de-rtmp-fu-wu-qi-da-jian/</id> |
| 16 | + <link href="https://newdy.cf/post/windows10-xia-nginx-de-rtmp-fu-wu-qi-da-jian/"> |
| 17 | + </link> |
| 18 | + <updated>2020-02-19T04:28:12.000Z</updated> |
| 19 | + <content type="html"><![CDATA[<ol> |
| 20 | +<li>下载 nginx 1.7.11.3 Gryphon<br> |
| 21 | + 下载链接: http://nginx-win.ecsds.eu/download/nginx 1.7.11.3 Gryphon.zip,下载完成后解压, 将解压后的目录命名为</li> |
| 22 | +</ol> |
| 23 | +<p>nginx-1.7.11.3-Gryphon<br> |
| 24 | +2. 下载服务器状态检查程序 stat.xsl(注:直接clone到nginx-1.7.11.3-Gryphon目录下)</p> |
| 25 | +<p>下载地址https://github.com/arut/nginx-rtmp-module/</p> |
| 26 | +<figure data-type="image" tabindex="1"><img src="https://newdy.cf/post-images/1582086527036.png" alt="" loading="lazy"></figure> |
| 27 | +<ol> |
| 28 | +<li>配置文件 conf\nginx-win-rtmp.conf 内容如下:(注:用记事本打开直接复制粘贴,避免编码格式引起错误)</li> |
| 29 | +</ol> |
| 30 | +<p>#user nobody;</p> |
| 31 | +<h1 id="multiple-workers-works">multiple workers works !</h1> |
| 32 | +<p>worker_processes 2;</p> |
| 33 | +<p>#error_log logs/error.log;<br> |
| 34 | +#error_log logs/error.log notice;<br> |
| 35 | +#error_log logs/error.log info;</p> |
| 36 | +<p>#pid logs/nginx.pid;</p> |
| 37 | +<p>events {<br> |
| 38 | +worker_connections 8192;<br> |
| 39 | +# max value 32768, nginx recycling connections+registry optimization =<br> |
| 40 | +# this.value * 20 = max concurrent connections currently tested with one worker<br> |
| 41 | +# C1000K should be possible depending there is enough ram/cpu power<br> |
| 42 | +# multi_accept on;<br> |
| 43 | +}</p> |
| 44 | +<p>rtmp {<br> |
| 45 | +server {<br> |
| 46 | +listen 1935;<br> |
| 47 | +chunk_size 4000;<br> |
| 48 | +application live {<br> |
| 49 | +live on;</p> |
| 50 | +<pre><code> # record first 1K of stream |
| 51 | + record all; |
| 52 | + record_path /tmp/av; |
| 53 | + record_max_size 1K; |
| 54 | +
|
| 55 | + # append current timestamp to each flv |
| 56 | + record_unique on; |
| 57 | +
|
| 58 | + # publish only from localhost |
| 59 | + allow publish 127.0.0.1; |
| 60 | + deny publish all; |
| 61 | +
|
| 62 | + #allow play all; |
| 63 | + } |
| 64 | +} |
| 65 | +</code></pre> |
| 66 | +<p>}</p> |
| 67 | +<p>http {<br> |
| 68 | +#include /nginx/conf/naxsi_core.rules;<br> |
| 69 | +include mime.types;<br> |
| 70 | +default_type application/octet-stream;</p> |
| 71 | +<pre><code>#log_format main '$remote_addr:$remote_port - $remote_user [$time_local] "$request" ' |
| 72 | +# '$status $body_bytes_sent "$http_referer" ' |
| 73 | +# '"$http_user_agent" "$http_x_forwarded_for"'; |
| 74 | +
|
| 75 | +#access_log logs/access.log main; |
| 76 | +</code></pre> |
| 77 | +<h1 id="loadbalancing-php"># loadbalancing PHP</h1> |
| 78 | +<h1 id="upstream-myloadbalancer">upstream myLoadBalancer {</h1> |
| 79 | +<h1 id="server-1270019001-weight1-fail_timeout5">server 127.0.0.1:9001 weight=1 fail_timeout=5;</h1> |
| 80 | +<h1 id="server-1270019002-weight1-fail_timeout5">server 127.0.0.1:9002 weight=1 fail_timeout=5;</h1> |
| 81 | +<h1 id="server-1270019003-weight1-fail_timeout5">server 127.0.0.1:9003 weight=1 fail_timeout=5;</h1> |
| 82 | +<h1 id="server-1270019004-weight1-fail_timeout5">server 127.0.0.1:9004 weight=1 fail_timeout=5;</h1> |
| 83 | +<h1 id="server-1270019005-weight1-fail_timeout5">server 127.0.0.1:9005 weight=1 fail_timeout=5;</h1> |
| 84 | +<h1 id="server-1270019006-weight1-fail_timeout5">server 127.0.0.1:9006 weight=1 fail_timeout=5;</h1> |
| 85 | +<h1 id="server-1270019007-weight1-fail_timeout5">server 127.0.0.1:9007 weight=1 fail_timeout=5;</h1> |
| 86 | +<h1 id="server-1270019008-weight1-fail_timeout5">server 127.0.0.1:9008 weight=1 fail_timeout=5;</h1> |
| 87 | +<h1 id="server-1270019009-weight1-fail_timeout5">server 127.0.0.1:9009 weight=1 fail_timeout=5;</h1> |
| 88 | +<h1 id="server-1270019010-weight1-fail_timeout5">server 127.0.0.1:9010 weight=1 fail_timeout=5;</h1> |
| 89 | +<h1 id="least_conn">least_conn;</h1> |
| 90 | +<h1 id="">}</h1> |
| 91 | +<pre><code>sendfile off; |
| 92 | +#tcp_nopush on; |
| 93 | +
|
| 94 | +server_names_hash_bucket_size 128; |
| 95 | +</code></pre> |
| 96 | +<h2 id="start-timeouts">Start: Timeouts</h2> |
| 97 | +<pre><code>client_body_timeout 10; |
| 98 | +client_header_timeout 10; |
| 99 | +keepalive_timeout 30; |
| 100 | +send_timeout 10; |
| 101 | +keepalive_requests 10; |
| 102 | +</code></pre> |
| 103 | +<h2 id="end-timeouts">End: Timeouts</h2> |
| 104 | +<pre><code>#gzip on; |
| 105 | +
|
| 106 | +server { |
| 107 | + listen 80; |
| 108 | + server_name localhost; |
| 109 | +
|
| 110 | +
|
| 111 | + location /stat { |
| 112 | + rtmp_stat all; |
| 113 | + rtmp_stat_stylesheet stat.xsl; |
| 114 | + } |
| 115 | + location /stat.xsl { |
| 116 | + root nginx-rtmp-module/; |
| 117 | + } |
| 118 | + location /control { |
| 119 | + rtmp_control all; |
| 120 | + } |
| 121 | +
|
| 122 | + #charset koi8-r; |
| 123 | + #access_log logs/host.access.log main; |
| 124 | +
|
| 125 | + ## Caching Static Files, put before first location |
| 126 | + #location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ { |
| 127 | + # expires 14d; |
| 128 | + # add_header Vary Accept-Encoding; |
| 129 | + #} |
| 130 | +</code></pre> |
| 131 | +<h1 id="for-naxsi-remove-the-single-line-for-learn-mode-or-the-lines-for-full-waf-mode">For Naxsi remove the single # line for learn mode, or the ## lines for full WAF mode</h1> |
| 132 | +<pre><code> location / { |
| 133 | + #include /nginx/conf/mysite.rules; # see also http block naxsi include line |
| 134 | + ##SecRulesEnabled; |
| 135 | + ##DeniedUrl "/RequestDenied"; |
| 136 | + ##CheckRule "$SQL >= 8" BLOCK; |
| 137 | + ##CheckRule "$RFI >= 8" BLOCK; |
| 138 | + ##CheckRule "$TRAVERSAL >= 4" BLOCK; |
| 139 | + ##CheckRule "$XSS >= 8" BLOCK; |
| 140 | + root html; |
| 141 | + index index.html index.htm; |
| 142 | + } |
| 143 | +</code></pre> |
| 144 | +<h1 id="for-naxsi-remove-the-lines-for-full-waf-mode-redirect-location-block-used-by-naxsi">For Naxsi remove the ## lines for full WAF mode, redirect location block used by naxsi</h1> |
| 145 | +<pre><code> ##location /RequestDenied { |
| 146 | + ## return 412; |
| 147 | + ##} |
| 148 | +</code></pre> |
| 149 | +<h2 id="lua-examples">Lua examples !</h2> |
| 150 | +<h1 id="location-robotstxt">location /robots.txt {</h1> |
| 151 | +<h1 id="rewrite_by_lua">rewrite_by_lua '</h1> |
| 152 | +<h1 id="if-ngxvarhttp_host-~-localhost-then">if ngx.var.http_host ~= "localhost" then</h1> |
| 153 | +<h1 id="return-ngxexecrobots_disallowtxt">return ngx.exec("/robots_disallow.txt");</h1> |
| 154 | +<h1 id="end">end</h1> |
| 155 | +<h1 id="-2">';</h1> |
| 156 | +<h1 id="-3">}</h1> |
| 157 | +<pre><code> #error_page 404 /404.html; |
| 158 | + # redirect server error pages to the static page /50x.html |
| 159 | + # |
| 160 | + error_page 500 502 503 504 /50x.html; |
| 161 | + location = /50x.html { |
| 162 | + root html; |
| 163 | + } |
| 164 | + # proxy the PHP scripts to Apache listening on 127.0.0.1:80 |
| 165 | + # |
| 166 | + #location ~ \.php$ { |
| 167 | + # proxy_pass http://127.0.0.1; |
| 168 | + #} |
| 169 | + # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 |
| 170 | + # |
| 171 | + #location ~ \.php$ { |
| 172 | + # root html; |
| 173 | + # fastcgi_pass 127.0.0.1:9000; # single backend process |
| 174 | + # fastcgi_pass myLoadBalancer; # or multiple, see example above |
| 175 | + # fastcgi_index index.php; |
| 176 | + # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; |
| 177 | + # include fastcgi_params; |
| 178 | + #} |
| 179 | + # deny access to .htaccess files, if Apache's document root |
| 180 | + # concurs with nginx's one |
| 181 | + # |
| 182 | + #location ~ /\.ht { |
| 183 | + # deny all; |
| 184 | + #} |
| 185 | +} |
| 186 | +# another virtual host using mix of IP-, name-, and port-based configuration |
| 187 | +# |
| 188 | +#server { |
| 189 | +# listen 8000; |
| 190 | +# listen somename:8080; |
| 191 | +# server_name somename alias another.alias; |
| 192 | +# location / { |
| 193 | +# root html; |
| 194 | +# index index.html index.htm; |
| 195 | +# } |
| 196 | +#} |
| 197 | +# HTTPS server |
| 198 | +# |
| 199 | +#server { |
| 200 | +# listen 443 ssl spdy; |
| 201 | +# server_name localhost; |
| 202 | +# ssl on; |
| 203 | +# ssl_certificate cert.pem; |
| 204 | +# ssl_certificate_key cert.key; |
| 205 | +# ssl_session_timeout 5m; |
| 206 | +# ssl_prefer_server_ciphers On; |
| 207 | +# ssl_protocols TLSv1 TLSv1.1 TLSv1.2; |
| 208 | +# ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:ECDH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!eNULL:!MD5:!DSS:!EXP:!ADH:!LOW:!MEDIUM; |
| 209 | +# location / { |
| 210 | +# root html; |
| 211 | +# index index.html index.htm; |
| 212 | +# } |
| 213 | +#} |
| 214 | +</code></pre> |
| 215 | +<p>}<br> |
| 216 | +4. 启动服务器</p> |
| 217 | +<p>nginx.exe -c conf\nginx-win-rtmp.conf<br> |
| 218 | +5.使用ffmpeg、ffplay进行推流拉流验证(直接ffmpeg官方下载windows下的可执行文件)</p> |
| 219 | +<p>5.1推流测试,使用ffmpeg命令完成即可</p> |
| 220 | +<p>ffmpeg.exe -re -i inputfile.mp4 -vcodec libx264 -acodec aac -f flv rtmp://localhost:1935/live/home<br> |
| 221 | +5.2拉流测试,使用ffplay命令完成即可<br> |
| 222 | +—————————————<br> |
| 223 | +ffplay.exe rtmp://localhost:1935/live/home<br> |
| 224 | +<img src="https://newdy.cf/post-images/1582086643460.png" alt="" loading="lazy"></p> |
| 225 | +]]></content> |
| 226 | + </entry> |
13 | 227 | <entry> |
14 | 228 | <title type="html"><![CDATA[Nginx-rtmp+ FFmpeg +Docker + vue.js 直播系统搭建]]></title> |
15 | 229 | <id>https://newdy.cf/post/nginx-rtmp-ffmpeg-docker-vuejs-zhi-bo-xi-tong-da-jian/</id> |
|
0 commit comments