The forum is here for legacy reasons. No new posts will be created. User registration is disabled! If you have any questions, please email us or check https://www.adultscriptpro.com for more details!
You are not logged in.
Hi,
Here's a small howto on how to configure lighttpd for FLV/H264 streaming and hotlinking protection. There are 2 scenarios, one is apache on port 80
for PHP and lighttpd on port 81 for streaming/leeching protection and lighttpd on port 80 for both php (fcgi) and streaming/leeching protection. In both cases
the same things apply.
For installing Lighttpd please check this thread: http://forum.adultscriptpro.com/viewtopic.php?id=577
Configure Lighttpd mod_flv_streaming and mod_h264_streaming modules in /etc/lighttpd/conf.d/h264.conf:
#### flv module
server.modules += ("mod_flv_streaming")
#### h264_module
server.modules += ("mod_h264_streaming")
# Files ending in .mp4 and .f4v are served by the module
h264-streaming.extensions = ( ".mp4", ".f4v" )
flv-streaming.extensions = (".flv")
# The number of seconds after which the bandwidth is shaped (defaults to 0=disable)
h264-streaming.buffer-seconds = 10
# Add Expires/Cache-Control header
$HTTP["url"] =~ "\.(mp4|f4v|flv)$" {
expire.url = ( "" => "access 8 hours" )
}
Configure Lighttpd mod_secdownload module in /etc/lighttpd/conf.d/secdownload.conf:
#######################################################################
##
## Secure Download Module
## ------------------------
##
## see http://www.lighttpd.net/documentation/secdownload.html
##
server.modules += ( "mod_secdownload" )
##
## Document root for the download area.
## The directory should not be below your normal
## document root!
##
secdownload.document-root = "/path/to/your/script/media/videos"
##
## Secret string that will be used for the checksum calculation.
##
secdownload.secret = "S3CR3tW0RD"
##
## How long is the secret valid?
##
## Default: 60 seconds
##
secdownload.timeout = 7200
##
## Prefix for the download area.
##
secdownload.uri-prefix = "/stream/"
The secdownload.secret and secdownload.uri-prefix will also be defined in Admin -> Video -> Config -> View (also for servers if multi-server is enabled, same thing for premium).
If you run apache on port 80 in order to prevent leeching you need to add a .htaccess rules to deny
access to the FLV/H264 files. Create a .htaccess file containing:
deny from all
in the following folders:
/where/your/script/is/media/videos/flv
/where/your/script/is/media/videos/mp4
/where/your/script/is/media/videos/mobile
You need to add the below lines (to lighttpd.conf or if you use vhosts, to your vhost file) in both cases in order to limit access to the files via lighttpd:
auth.require = (
"/media/videos/flv/" => (
"method" => "digest",
"realm" => "Authorized users only",
"require" => "valid-user"
),
"/media/videos/mp4/" => (
"method" => "digest",
"realm" => "Authorized users only",
"require" => "valid-user"
),
"/media/videos/mobile/" => (
"method" => "digest",
"realm" => "Authorized users only",
"require" => "valid-user"
)
)
Once everything is configured, the video files can only be accessed via a lighttpd secdownload URL and this URL will change every 2 hours, so basically
nobody will be able to leech/hotlink your videos.
NOTE: By no means this is 100% secure, but in 99% of the cases it will stop the leeching. If you want the best security you have to use a media server (like flash media server, red5 or wowza), however most people use lighttpd or nginx.
NOTE2: I've found a free media streaming server (http://www.rtmpd.com/), but i have to checkout if it supports what we need.
Adult Scripts: Adult Script Pro - Adult Search Script
Adult Advertising/Traffic: Plug Rush - EXOClick - PopAds
Offline
also some info that will save you bandwith and make the streaming faster
connection.kbytes-per-second = 100
## simply put "mod_evasive" into the server.modules list
evasive.max-conns-per-ip = 3
## 1024 by default but 2048 is a better default for busy servers
server.max-fds = 2048
server.stat-cache-engine = "simple"
server.event-handler = "linux-sysepoll"
server.max-keep-alive-requests = 4
server.max-keep-alive-idle = 2
## writev - is recommended for sending many large files up to 10MB
server.network-backend = "writev"
## If you have to serve a lot of large files with a high concurrency, you will notice that you will be IO-bound
to your hard-drive. lighty will spend most of the time waiting for the hard-drive to seek to the right
sector to send out the file. As lighty will wait for the disk, all connections in the process will have to wait. In order to process more requests concurrently, you should create 4 to 16 work processes. This will allow you to both send and wait for data at the same time.
server.max-worker = 4
Last edited by Eri (2011-07-27 07:49:56)
Offline
server.network-backend = "writev"
Is pretty good, but it only works if you use lighttpd only for streaming (i personally serve everything with lighttpd). Also there is another conf option in lighttpd for restricting the amount of bandwidth a connection can use at a time, making sure that if someone has 20MBps connection he wont eat bandwith that he doesnt need (basically limiting to max 2MBps for example).
Adult Scripts: Adult Script Pro - Adult Search Script
Adult Advertising/Traffic: Plug Rush - EXOClick - PopAds
Offline
Yes , my servers are only for video sreaming.
Also there is a problem with "evasive.max-conns-per-ip = 3" when someone seek video more than three times get's an error connection :@
What settings do you make with lighttpd for faster streaming?
Offline
Except for what has been posted in this topic, nothing else.
Adult Scripts: Adult Script Pro - Adult Search Script
Adult Advertising/Traffic: Plug Rush - EXOClick - PopAds
Offline
This is still giving me problems in updating lighttpd..can u please help me
Offline
Hi,
If you run apache on port 80 in order to prevent leeching you need to add a .htaccess rules to deny
access to the FLV/H264 files. Create a .htaccess file containing:deny from all
in the following folders:
/where/your/script/is/media/videos/flv /where/your/script/is/media/videos/mp4 /where/your/script/is/media/videos/mobile
You need to add the below lines in both cases in order to limit access to the files via lighttpd:
auth.require = ( "/media/videos/flv/" => ( "method" => "digest", "realm" => "Authorized users only", "require" => "valid-user" ), "/media/videos/mp4/" => ( "method" => "digest", "realm" => "Authorized users only", "require" => "valid-user" ), "/media/videos/mobile/" => ( "method" => "digest", "realm" => "Authorized users only", "require" => "valid-user" ) )
Once everything is configured, the video files can only be accessed via a lighttpd secdownload URL and this URL will change every 2 hours, so basically
nobody will be able to leech/hotlink your videos.NOTE: By no means this is 100% secure, but in 99% of the cases it will stop the leeching. If you want the best security you have to use a media server (like flash media server, red5 or wowza), however most people use lighttpd or nginx.
in this part i do not know what to do
1) i should replace the script .htaccess ??
2)
where goes this code??
auth.require = (
"/media/videos/flv/" => (
"method" => "digest",
"realm" => "Authorized users only",
"require" => "valid-user"
),
"/media/videos/mp4/" => (
"method" => "digest",
"realm" => "Authorized users only",
"require" => "valid-user"
),
"/media/videos/mobile/" => (
"method" => "digest",
"realm" => "Authorized users only",
"require" => "valid-user"
)
)
3) when i done with this steps my server will start run with Lighttpd ?
Offline
@jason3107: what exactly is the problem?
@thiva7:
1. You need to create a .htaccess file in the following folders media/videos/flv, media/videos/mp4 and media/videos/mobile (actually the .htaccess file is there already just uncomment the deny from all line).
2. Those files are used in lighttpd, you can put them in /etc/lighttpd/conf.d/auth.conf
3. Your server will use lighttpd to stream videos, The PHP and other files will still be served by apache.
Adult Scripts: Adult Script Pro - Adult Search Script
Adult Advertising/Traffic: Plug Rush - EXOClick - PopAds
Offline
@jason3107: what exactly is the problem?
@thiva7:
1. You need to create a .htaccess file in the following folders media/videos/flv, media/videos/mp4 and media/videos/mobile (actually the .htaccess file is there already just uncomment the deny from all line).
2. Those files are used in lighttpd, you can put them in /etc/lighttpd/conf.d/auth.conf
3. Your server will use lighttpd to stream videos, The PHP and other files will still be served by apache.
IN WICH LINE I CAN ADD IT?
#######################################################################
##
## Authentication Module
## -----------------------
##
## See http://www.lighttpd.net/documentation/a … ation.html
## for more info.
###auth.backend = "plain"
#auth.backend.plain.userfile = "/etc/lighttpd/lighttpd.user"
#auth.backend.plain.groupfile = "/etc/lighttpd/lighttpd.group"#auth.backend.ldap.hostname = "localhost"
#auth.backend.ldap.base-dn = "dc=my-domain,dc=com"
#auth.backend.ldap.filter = "(uid=$)"#auth.require = ( "/server-status" =>
# (
# "method" => "digest",
# "realm" => "Server Status",
# "require" => "valid-user"
# ),
# )##
#######################################################################
Offline
Make sure you have the auth module enabled in /etc/lighttpd/modules.conf and then you can add in the /etc/lighttpd/conf.d/auth.conf file.
Adult Scripts: Adult Script Pro - Adult Search Script
Adult Advertising/Traffic: Plug Rush - EXOClick - PopAds
Offline
Offline
Mount that HD somewhere in your Server, then create a subdomain and set the path to the root of that subdomain to the path where you have mounted the hd. Then add a server in ACP with that subdomain you created before
Last edited by Coscast (2011-10-18 12:02:59)
Offline
Offline
Yes...i've been having a few problems with lighttpd streaming also (not my own sites, though). Exactly the same lighttpd version, same compile options and it simply crashes. What module are you using for apache streaming? Also do you have any hotlinking prevention with apache?
Adult Scripts: Adult Script Pro - Adult Search Script
Adult Advertising/Traffic: Plug Rush - EXOClick - PopAds
Offline
So Which One We Use lighttpd Or Without It And How To Use Script On Cloud Server Without Server Management Facility. I Found A Good Reasonable Price Cloud But they Do Not Provide Server Management So Any Help To Use Them I Like To try Site On Cloud.
Offline
Usually you cant install anything on cloud hosting...so your limited to what they already have installed.
Adult Scripts: Adult Script Pro - Adult Search Script
Adult Advertising/Traffic: Plug Rush - EXOClick - PopAds
Offline
hello,
I did everything here, but when trying to play the video it says:
200, Stream not found, NetStream.Play.StreamNotFound, clip: '[Clip] 'http://kosimak.com:81/stream/ff3c91b6fdb93253420edefdf3da8c4c/4f1dcfb0/flv/3.flv''
any idea?
Offline
Please email me ssh root access. I can configure this for you.
Adult Scripts: Adult Script Pro - Adult Search Script
Adult Advertising/Traffic: Plug Rush - EXOClick - PopAds
Offline
hello,
I did everything here, but when trying to play the video it says:
200, Stream not found, NetStream.Play.StreamNotFound, clip: '[Clip] 'http://kosimak.com:81/stream/ff3c91b6fdb93253420edefdf3da8c4c/4f1dcfb0/flv/3.flv''
any idea?
Make sure to set server.document-root = "/home/USER/public_html" in the /etc/lighttpd/lighttpd.conf for anyone getting 404 issues.
However, I now am experiencing an issue with loading content from http://127.0.0.1:8080/media/videos/flv/8.flv. 403 Forbidden to be exact.
I have
server.username = "lighttpd"
server.groupname = "lighttpd"
in the conf.
But changing the videos folder and everything in it to lighttpd:lighttpd does nothing. Still 403.
Last edited by Tenche (2012-07-08 19:09:16)
Offline
Comment the server.username and server.groupname with # in the lighttpd.conf file and then restart lighttpd.
Adult Scripts: Adult Script Pro - Adult Search Script
Adult Advertising/Traffic: Plug Rush - EXOClick - PopAds
Offline
Comment the server.username and server.groupname with # in the lighttpd.conf file and then restart lighttpd.
Done. Works. Thanks!
Offline
use apache streaming is more stable
No thanks. If anything, I'd switch to nginx
Offline
server.max-keep-alive-requests = 4
server.max-keep-alive-idle = 2
Should i uncomment those two lines? they currently have the # sign in front.
Last edited by DuttyRock (2012-09-15 19:03:29)
Offline