{"id":2404,"date":"2015-08-31T13:05:41","date_gmt":"2015-08-31T05:05:41","guid":{"rendered":"http:\/\/blog.hoyo.idv.tw\/?p=2404"},"modified":"2015-08-31T13:08:31","modified_gmt":"2015-08-31T05:08:31","slug":"apache-token","status":"publish","type":"post","link":"https:\/\/blog.hoyo.idv.tw\/?p=2404","title":{"rendered":"Apache Token"},"content":{"rendered":"<p>\u4ecb\u7d39\u4ee5\u5f80\u5be6\u4f5c\u904e\u7684 MP4 \u4e32\u6d41 + \u63a7\u7ba1\u65b9\u5f0f\uff0c\u73fe\u5728\u5df2\u7d93\u6709 PHP \u5be6\u4f5c\u7684\u65b9\u5f0f\uff0c\u4e0d\u63a8\u85a6\u6b64\u7a2e\u65b9\u5f0f\u3002<\/p>\n<p>--<\/p>\n<p>mod_auth_token \u63d0\u4f9b\u4e00\u500b\u6709\u6642\u6548\u6027\u7684\u52a0\u5bc6\u7db2\u5740 <a href=\"http:\/\/wiki.paskvil.com\/index.php\/Install_Apache_and_PHP_to_do_Secure_h264_Pseudo_Streaming\">Install Apache and PHP to do Secure h264 Pseudo Streaming - PaskvilWiki<\/a>\u00a0(<a href=\"http:\/\/blog.hoyo.idv.tw\/wp-content\/uploads\/2012\/09\/Install-Apache-and-PHP-to-do-Secure-h264-Pseudo-Streaming-PaskvilWiki.htm\" target=\"_blank\">\u672c\u6a5f\u5099\u4efd<\/a>) \u4e0b\u5217\u6307\u4ee4\u6839\u64da OpenSUSE 11.2 \u4ee5\u53ca\u500b\u4eba\u4f7f\u7528\u7fd2\u6163\u4fee\u6539\u904e\u4e86\u3002<\/p>\n<pre class=\"lang:sh decode:true\">yast -i automake\r\ncd ~\r\nwget \"http:\/\/mod-auth-token.googlecode.com\/files\/mod_auth_token-1.0.5.tar.gz\"\r\ntar zxf mod_auth_token-1.0.5.tar.gz\r\nsudo rm missing\r\nsudo ln -s \/usr\/share\/automake-1.11\/missing missing\r\nsudo rm config.guess\r\nsudo ln -s \/usr\/share\/automake-1.11\/config.guess config.guess\r\nsudo rm config.sub\r\nsudo ln -s \/usr\/share\/automake-1.11\/config.sub config.sub\r\nsudo rm COPYING\r\nsudo ln -s \/usr\/share\/automake-1.11\/COPYING COPYING\r\nsudo rm install-sh\r\nsudo ln -s \/usr\/share\/automake-1.11\/install-sh install-sh\r\nsudo .\/configure\r\nmake ; make check\r\nmake install\r\n\/etc\/rc.d\/apache2 restart<\/pre>\n<p>\u7de8\u8f2f Apache \u7db2\u7ad9\u8a2d\u5b9a \u6b64\u8655\u4e0d\u540c\u7684\u5730\u65b9\u662f\u79fb\u9664\u4e86\u00a0AuthTokenLimitByIp \uff0c\u90a3\u662f 1.0.6 \u7248\u672c\u624d\u53ef\u4f7f\u7528\u7684\u53c3\u6578\u3002<\/p>\n<pre class=\"lang:ini decode:true\"># Disable direct access to the folder\r\n&lt;Directory \/Multimedia&gt;\r\n AllowOverride None\r\n allow from all\r\n&lt;\/Directory&gt;\r\nScriptAlias \/Multimedia\/ \/Multimedia\/\r\n# Token settings\r\n&lt;Location \/Multimedia\/&gt;\r\n AuthTokenSecret \"mysecretstring\"\r\n AuthTokenPrefix \/Multimedia\/\r\n AuthTokenTimeout 10\r\n&lt;\/Location&gt;<\/pre>\n<p>\u7ba1\u5236\u7684\u76ee\u9304\u6709\u6c92\u6709\u5728\u7db2\u7ad9\u5167\u90fd\u7121\u6240\u8b02\uff0c\u56e0\u70ba\u8a72\u76ee\u9304\u53ef\u4f7f\u7528\u00a0ScriptAlias \u5c0e\u5f15\uff0c\u800c\u4e14\u7576 mod_auth_token \u751f\u6548\u6642\uff0c\u4e00\u5b9a\u8981\u900f\u904e\u904b\u7b97\u751f\u6548\u7684\u7db2\u5740\u624d\u53ef\u4e0b\u8f09\u4f7f\u7528\u3002 \u7522\u751f\u4e0b\u8f09\u7db2\u5740<\/p>\n<pre class=\"lang:php decode:true\">&lt;?php\r\n\/\/ Settings to generate the URI\r\n$secret = \"mysecretstring\"; \/\/ Same as AuthTokenSecret\r\n$protectedPath = \"\/Multimedia\/\"; \/\/ Same as AuthTokenPrefix\r\n$hexTime = dechex(time()); \/\/ Time in Hexadecimal\r\n$fileName = \"\/test.mp4\"; \/\/ The file to access\r\n\r\n$token = md5($secret . $fileName. $hexTime);\r\n\r\n\/\/ We build the url\r\n$url = $protectedPath . $token. \"\/\" . $hexTime . $fileName;\r\n<\/pre>\n<p>\u7522\u751f\u7684\u7db2\u5740\u5927\u6982\u9577\u9019\u500b\u6a23\u5b50<\/p>\n<pre class=\"\">\/Multimedia\/ed60099baf58e663468348fe368bf35c\/5057d728\/test.mp4<\/pre>\n<p>\u76f4\u63a5\u5230\u00a0\/Multimedia\/A2.mp4 \u6703\u51fa\u73fe HTTP 401 Authentication required!\u00a0\u932f\u8aa4\uff0c\u903e\u6642\u624d\u9023\u7d50\u6703\u51fa\u73fe HTTP 410\u00a0Resource is no longer available! \u932f\u8aa4\u3002<\/p>\n<p>\u8a72\u9023\u7d50\u5373\u7121\u6cd5\u91cd\u8907\u4f7f\u7528\uff0c\u4e0b\u70ba\u91cd\u8907\u4f7f\u7528\u7684\u932f\u8aa4\u8a0a\u606f<\/p>\n<pre class=\"lang:default decode:true brush: bash; gutter: true\">Gone\r\n\r\nThe requested resource\r\n\/Multimedia\/46017c47f301d168cf695eac9951b29f\/50b57357\/test.mp4\r\nis no longer available on this server and there is no forwarding address. Please remove all references to this resource.<\/pre>\n<p class=\"brush: bash; gutter: true\"><a href=\"http:\/\/blog.hoyo.idv.tw\/wp-content\/uploads\/2012\/09\/\u5716\u7247-018.png\" data-rel=\"lightbox-image-0\" data-rl_title=\"\" data-rl_caption=\"\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-937\" title=\"\" src=\"http:\/\/blog.hoyo.idv.tw\/wp-content\/uploads\/2012\/09\/\u5716\u7247-018.png\" alt=\"\" width=\"710\" height=\"126\" srcset=\"https:\/\/blog.hoyo.idv.tw\/wp-content\/uploads\/2012\/09\/\u5716\u7247-018.png 710w, https:\/\/blog.hoyo.idv.tw\/wp-content\/uploads\/2012\/09\/\u5716\u7247-018-300x53.png 300w, https:\/\/blog.hoyo.idv.tw\/wp-content\/uploads\/2012\/09\/\u5716\u7247-018-500x88.png 500w\" sizes=\"(max-width: 710px) 100vw, 710px\" \/><\/a><\/p>\n<div class=\"pvc_clear\"><\/div>\n<p class=\"pvc_stats all \" data-element-id=\"2404\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> &nbsp;1,276&nbsp;total views<\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u4ecb\u7d39\u4ee5\u5f80\u5be6\u4f5c\u904e\u7684 MP4 \u4e32\u6d41...<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p class=\"pvc_stats all \" data-element-id=\"2404\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> &nbsp;1,276&nbsp;total views<\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[31],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/2404"}],"collection":[{"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2404"}],"version-history":[{"count":5,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/2404\/revisions"}],"predecessor-version":[{"id":2409,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/2404\/revisions\/2409"}],"wp:attachment":[{"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2404"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2404"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2404"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}