# cloudroom **Repository Path**: scorpio_cc/cloudroom ## Basic Information - **Project Name**: cloudroom - **Description**: QWERTYUIKLBH;NJMK - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-07-26 - **Last Updated**: 2023-10-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README nginx访问配置 location /cloudroomManagement/ { proxy_pass http://127.0.0.1:8081; } location /cloudroom/ { root F://idea-xja//cloudroom//src//main//resources//static;#(此路径为项目中页面路径,可单独存放) index index.html index.htm; } 为防止用户未登录即可访问视频文件,在nginx中增加lua验证,验证用户的jwt,验证是否有观看权限 location ~ ^/video.*\.(ts|m3u8)$ { rewrite_by_lua_block { local cjson = require "cjson" local http = require "resty.http" local httpc = http.new() local ngx = ngx local headers = ngx.req.get_headers() local token = headers["token"] local currentTime = headers["currentTime"] local videoId = headers["videoId"] if not token then ngx.header['Content-Type'] = 'text/plain; charset=utf-8'; ngx.status = ngx.HTTP_FORBIDDEN ngx.say("You do not have permission to view the video.") ngx.exit(200) end local url = "http://127.0.0.1:8081/cloudroomManagement/checkToken?token="..token.."¤tTime="..currentTime.."&videoId="..videoId; local res, err = httpc:request_uri(url, {method="GET", headers={["token"]=token}}) if not res then ngx.header['Content-Type'] = 'text/plain; charset=utf-8'; ngx.say(cjson.encode({message = "Error getting response",status = ngx.HTTP_INTERNAL_SERVER_ERROR })); ngx.exit(200) end if res.body == '0' then ngx.header['Content-Type'] = 'text/plain; charset=utf-8'; ngx.say("You do not have permission to view the video."); ngx.exit(200) end if res.body == '3' then ngx.header['Content-Type'] = 'video/mp2t'; ngx.exit(200) end } types{ application/vnd.apple.mpegurl m3u8; video/mp2t ts; } root F://; add_header Cache-Control no-cache; add_header Access-Control-Allow-Origin *; } location ~ ^/video/.*/key { rewrite_by_lua_block { local cjson = require "cjson" local http = require "resty.http" local httpc = http.new() local ngx = ngx local headers = ngx.req.get_headers() local token = headers["token"] local currentTime = headers["currentTime"] local videoId = headers["videoId"] if not token then ngx.header['Content-Type'] = 'text/plain; charset=utf-8'; ngx.status = ngx.HTTP_FORBIDDEN ngx.say("You do not have permission to view the video.") ngx.exit(200) end local url = "http://127.0.0.1:8081/cloudroomManagement/checkToken?token="..token.."¤tTime="..currentTime.."&videoId="..videoId; local res, err = httpc:request_uri(url, {method="GET", headers={["token"]=token}}) if not res then ngx.header['Content-Type'] = 'text/plain; charset=utf-8'; ngx.say(cjson.encode({message = "Error getting response",status = ngx.HTTP_INTERNAL_SERVER_ERROR })); ngx.exit(200) end if res.body == '0' then ngx.header['Content-Type'] = 'text/plain; charset=utf-8'; ngx.say("You do not have permission to view the video."); ngx.exit(200) end if res.body == '3' then ngx.header['Content-Type'] = 'video/mp2t'; ngx.exit(200) end } types{ application/vnd.apple.mpegurl m3u8; video/mp2t ts; } root F://; add_header Cache-Control no-cache; add_header Access-Control-Allow-Origin *; }