- Lighttpd
- Andre Bogus
- 376字
- 2021-08-25 18:06:24
Putting it All Together
As we have seen on the last pages, Lighttpd has a lot to offer for setting up a download or streaming server. But we might be puzzled about how they relate to each other, and how we can use them together for optimal benefit. Therefore, here is a huge example configuration that has it all:
# use all modules we need server.modules = (..., "mod_rewrite", "mod_trigger_b4_dl", "mod_flv_streaming", "mod_evasive", "mod_extforward", "mod_secdownload", "mod_alias", "mod_accesslog", ...) server.document-root = "/web/public" # use the rewrite trick $HTTP["cookie"] =~ "download/([0-9a-f]){32}/([0-9a-f]){8}" { url.rewrite = ("/download/(.*)$" => "/download/%1/%2/$1") } else { # rewrite to avert mod_secdownload url.rewrite = ("^/download/" => "/freeload/") } # configure mod_secdownload secdownload.secret = "foo bar qux!!!1one!eleven" secdownload.document-root = server.document-root secdownload.uri-prefix = "/download/" secdownload.timeout = 120 # configure mod_dirlisting dir-listing.exclude = ("~$", "\.old$") dir-listing.show-header = "enable" dir-listing.hide-header-file = "enable" dir-listing.external-css = "/css/dir.css" # or use a dir listing generator # (see chapter 3 for PHP configuration) # server.index_files = ("index.html", "/dirlisting.php") $HTTP["url"] =~ "^/download/([0-9a-f]){32}/([0-9a-f]){8}/" { # paying customers, full speed server.backend = "posix-aio" server.kbytes-per-second = 0 connection.kbytes-per-second = 0 # make it easy on the paying customer server.max-write-idle = 720 # they pay, we trust extforward.forwarder = ("all" => "trust") dir-listing.activate = "enable" dir-listing.set-footer = "Thanks for trusting <a\ href=\"http://ourdomain.com\">ourdomain.com</a>!" # finally, allow streaming flv-streaming.extensions = ( ".flv" ) } else $HTTP["url"] =~ "^/freeload" { # also downloads, so use the best backend server.backend = "posix-aio" # re-redirect internally to circumvent mod_secdownload. We could # also use a different directory with symbolic links alias.url = ("/freeload" => "/download") # anonymous freeloaders, support by ads trigger-before-download.gdbm-filename = "/web/internal/ad_trigger.db" trigger-before-download.trigger-url = "^/ads/" trigger-before-download.download-url = "^/download/" trigger-before-download.deny-url = "/no-ads-no-downloads.html" trigger-before-download.trigger-timeout = 5 dir-listing.activate = "enable" dir-listing.set-footer = "Why not <a\ href=\"http://ourdomain.com/sign.html\">sign up</a>?" # also traffic-shape, make it sloooow server.kbytes-per-second = 1024 connection.kbytes-per-second = 32 evasive.max-conns-per-ip = 2 # and throttle keepalives to close sessions earlier server.max-keepalive-requests = 8 server.max-keepalive-idle = 5 # allow streaming anyway flv-streaming.extensions = ( ".flv" ) }
With this configuration, our Lighttpd is a true download server. Note that most of this configuration has little or no side effects. So we can also use our Lighttpd for other purposes in parallel. By the way, if you want to use the above configuration, download the downloadserver.conf
file from http://www.packtpub.com/files/code/2103_Code.zip.
推薦閱讀
- Painter 現代服裝效果圖表現技法
- Vulkan學習指南
- 工業產品設計(Inventor 2010)
- Adobe 創意大學動漫設計師Flash CS5 + Photoshop CS5 標準實訓教材
- Authorware應用案例教程
- Android從入門到精通
- 中文版CorelDRAW X6基礎培訓教程(第2版)
- 會聲會影視頻編輯實戰秘技250招
- RAW 數碼底片演義
- CorelDRAW X6核心應用案例教程(全彩慕課版)
- 行攝 Photoshop CC后期修片高手之道(第2版)
- After Effects印象 影視高級特效光影篇
- MATLAB在日常計算中的應用
- AutoCAD 2016從入門到精通
- Photoshop CS6 中文版從入門到精通