蘭雅sRGB 个人笔记 https://262235.xyz
提供编程和电脑应用视频教程,工具和源代码
C, C++, Python Programming, Source Code, Video

旧Hexo博客 | Github | IP定位WebAPI | Docker Hub
编程中文文档 | 网盘分享 | 中文Linux命令

私人云盘搭建之 Nginx https代理 Emby 网络视频播放

Cloud.jpg

Emby(原名Media Browser)是一个主从式架构的媒体服务器软件,可以用来整理服务器上的视频和音频,并将音频和视频流式传输到客户端设备。

Emby服务器端支持Microsoft Windows、Linux、MacOS、FreeBSD,客户端支持HTML5网页,Android和IOS等移动操作系统,Roku、Amazon Fire TV、Chromecast和Apple TV等流媒体设备,LG智能电视和三星智能电视等智能电视,以及Xbox 360和Xbox One等游戏机。

Emby 网络视频播放 搭建

docker run -d \
  --name=emby \
  -e PUID=1000 \
  -e PGID=1000 \
  -p 8096:8096 \
  -v /mnt/emby:/config \
  -v /mnt/downloads:/data/movies \
  --restart unless-stopped \
  emby/embyserver

影视下载软件: qbittorrent 安装

安装Nginx 代理 Emby 网络视频播放

启动 nginx-php-fpm7.3 容器

docker run -d -p 80:80 -p 443:443  \
    --cpus 0.8   --restart=always   \
    -v /var/www/html:/var/www/html   \
    --name  nginx-php      \
    hongwenjun/nginx-php

Nginx 反代理 Emby 网页

https.png

  • 如图,操作命令

    cd /var/www/html
    vim https.conf   # 粘贴下面配置
    
    # 检查 Emby服务的端口和内网
    iptables -L | grep 8096
    
    # 进入容器配置 修改Nginx配置
    docker exec -it nginx-php bash
    
    cd /etc/nginx/sites-enabled/
    ls
    cp /var/www/html/https.conf default
    nginx  -t
    nginx -s reload
    

    网页访问 http://188.188.188.188/emby 完成 emby 配置

emby.png

  • 测试用 https.conf 配置参考

    server {
          listen 80 default_server;
          listen [::]:80 default_server;
    
          # listen 443 ssl default_server;
          # listen [::]:443 ssl default_server;
    
          root /var/www/html;
          index index.html index.php index.nginx-debian.html;
          server_name _;
    
          location / {
                  try_files $uri $uri/ =404;
          }
    
      location /emby/ {
          # Proxy main Jellyfin traffic
          proxy_pass http://172.17.0.3:8096;
          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_set_header X-Forwarded-Protocol $scheme;
          proxy_set_header X-Forwarded-Host $http_host;
          
          # Disable buffering when the nginx proxy gets very resource heavy upon streaming
          proxy_buffering off;
      }
    
          # pass PHP scripts to FastCGI server
          location ~ .*\.php(\/.*)*$ {
                  include snippets/fastcgi-php.conf;
          #       # With php-fpm (or other unix sockets):
                  fastcgi_pass unix:/run/php/php7.3-fpm.sock;
          }
    
    }

    申请域名和获得免费证书,请自行 google

    m.26235.png

    网站启用 SSL 使用 Https 访问,浏览器不会不安全警告

  • SSL证书启用 https.conf 配置参考,请在本地编辑好,使用scp上传

    server {
    
     listen 443 ssl default_server;
     listen [::]:443 ssl default_server;
    
     server_name m.262235.xyz;
     ssl_certificate m.262235.xyz.crt;
     ssl_certificate_key m.262235.xyz.key;
    
     ssl_session_timeout 5m;
     ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    
     ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
     ssl_prefer_server_ciphers on;
    
     root /var/www/html;
     index index.html index.php index.nginx-debian.html;
    
     location / {
       try_files $uri $uri/ =404;
       }
    
     location /emby/ {
       proxy_pass http://172.17.0.3:8096;
       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_set_header X-Forwarded-Protocol $scheme;
       proxy_set_header X-Forwarded-Host $http_host;
    
       # Disable buffering when the nginx proxy gets very resource heavy upon streaming
       proxy_buffering off;
       }
    
       # pass PHP scripts to FastCGI server
       location ~ .*\.php(\/.*)*$ {
       include snippets/fastcgi-php.conf;
       # fastcgi_pass 127.0.0.1:9000;
       # With php-fpm (or other unix sockets):
       fastcgi_pass unix:/run/php/php7.3-fpm.sock;
     }
    
    }
    
    server {
       listen 80; 
       server_name m.262235.xyz;
       return 301 https://$host$request_uri;
    }
  • 使用scp工具上传 证书和 https配置,命令行参考

    # 上传证书 到 用户 root 目录下
    scp m.262235.xyz.crt [email protected]:/root/.
    scp m.262235.xyz.key [email protected]:/root/.
    scp https.conf       [email protected]:/root/.
  • 把配置复制到容器 nginx-php 中,启用配置

    docker ps -a
    docker cp m.262235.xyz.crt nginx-php:/etc/nginx/.
    docker cp m.262235.xyz.key nginx-php:/etc/nginx/.
    docker cp https.conf       nginx-php:/etc/nginx/conf.d/.
    
    docker restart nginx-php
    docker logs  nginx-php
    
    # 如果启动有错误,可以进入容器检查,还有也可以删除 /etc/nginx/sites-enabled/default
  • 编辑主页: vim /var/www/html/index.html

    <!DOCTYPE html><html lang="en"><head><meta charset="utf-8" /><title>私人云盘:网络视频播放</title>
    <html><body style="text-align:center;">
    <a href="https://m.262235.xyz/emby"><img src="https://262235.xyz/usr/uploads/2021/06/1343102762.jpg" ></img></a><bar>
    点击图片进入<bar>
    <p><p><p>
    参考文章: <a href="https://262235.xyz/index.php/archives/141/">私人云盘搭建之 Nginx https代理 Emby 网络视频播放<a><bar>
    </html>
本原创文章自由转载,转载请注明本博来源及网址 | 当前页面:兰雅sRGB个人笔记 » 私人云盘搭建之 Nginx https代理 Emby 网络视频播放