我正在尝试创build一个应用程序,它将在基于meteor / nodejs的学习环境中显示video。 问题是stream媒体本身。 正如许多页面所描述的,节点不适合用于静态内容。
所以我的想法是让我的nginx服务器为video服务。
问题是:这些video不应该是公开的,他们只能访问有权查看该video的login用户。
有没有办法configurationnginx让只有login到我的应用程序,并有权查看video查看video的用户?
什么是最好的方法?
这确实是正确的做法。
通过使用--with-http_auth_request_module标志重新编译nginx来包含auth_request模块(不是默认生成的)。
有了它,您将能够使用发送到您的应用程序的子请求的HTTP代码来授予或拒绝对内容的访问。
基本上,你将在你的应用程序中编写一个控制器来回应身份validation检查的请求,并用HTTP 200或403来禁止它。
location /video { auth_request /access; [ ... ] } location = /access { internal; proxy_http_version 1.1; proxy_set_header Connection ""; proxy_set_header Content-Length ""; proxy_set_header X-Original-URI $request_uri; proxy_pass_request_body off; proxy_pass http://my_server_app:port/my_controller; }