Adult Script Pro Community Forums

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.

#1 2011-07-17 19:21:44

symtab
Administrator
Registered: 2010-08-23
Posts: 7,501
Website

[HOWTO] Configure Lighttpd for Streaming and Hotlinking Protection

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

#2 2011-07-27 07:26:50

Eri
Member
Registered: 2011-03-18
Posts: 977

Re: [HOWTO] Configure Lighttpd for Streaming and Hotlinking Protection

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)


Best Adult Affilitate Network:
ExoClick
Best Deals on Dedicated Servers - CDN
INXY

Offline

#3 2011-07-27 09:52:19

symtab
Administrator
Registered: 2010-08-23
Posts: 7,501
Website

Re: [HOWTO] Configure Lighttpd for Streaming and Hotlinking Protection

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

#4 2011-07-29 09:25:28

Eri
Member
Registered: 2011-03-18
Posts: 977

Re: [HOWTO] Configure Lighttpd for Streaming and Hotlinking Protection

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?


Best Adult Affilitate Network:
ExoClick
Best Deals on Dedicated Servers - CDN
INXY

Offline

#5 2011-07-29 15:49:16

symtab
Administrator
Registered: 2010-08-23
Posts: 7,501
Website

Re: [HOWTO] Configure Lighttpd for Streaming and Hotlinking Protection

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

#6 2011-08-29 10:31:49

jason3107
Member
Registered: 2011-07-15
Posts: 2

Re: [HOWTO] Configure Lighttpd for Streaming and Hotlinking Protection

This is still giving me problems in updating lighttpd..can u please help me

Offline

#7 2011-08-29 12:51:05

thiva7
Member
Registered: 2011-04-30
Posts: 1,022

Re: [HOWTO] Configure Lighttpd for Streaming and Hotlinking Protection

symtab wrote:

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 sad

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

#8 2011-08-29 13:53:13

symtab
Administrator
Registered: 2010-08-23
Posts: 7,501
Website

Re: [HOWTO] Configure Lighttpd for Streaming and Hotlinking Protection

@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

#9 2011-08-29 14:14:25

thiva7
Member
Registered: 2011-04-30
Posts: 1,022

Re: [HOWTO] Configure Lighttpd for Streaming and Hotlinking Protection

symtab wrote:

@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

#10 2011-08-29 18:32:30

symtab
Administrator
Registered: 2010-08-23
Posts: 7,501
Website

Re: [HOWTO] Configure Lighttpd for Streaming and Hotlinking Protection

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

#11 2011-10-18 11:51:50

Eri
Member
Registered: 2011-03-18
Posts: 977

Re: [HOWTO] Configure Lighttpd for Streaming and Hotlinking Protection

My HD is full with videos and i bought a secondary HD.
What i will do to get my new videos stored at my secondary HD at the same server?


Best Adult Affilitate Network:
ExoClick
Best Deals on Dedicated Servers - CDN
INXY

Offline

#12 2011-10-18 12:02:30

Coscast
Member
From: Germany
Registered: 2010-10-03
Posts: 546

Re: [HOWTO] Configure Lighttpd for Streaming and Hotlinking Protection

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 smile

Last edited by Coscast (2011-10-18 12:02:59)


sgt-halfsize-banner.jpg

Offline

#13 2011-12-14 13:43:09

Eri
Member
Registered: 2011-03-18
Posts: 977

Re: [HOWTO] Configure Lighttpd for Streaming and Hotlinking Protection

Guys , I have changed to Apache streaming and is much faster , I was getting servers downtime with lighhttpd. With Apache i am ok now smile


Best Adult Affilitate Network:
ExoClick
Best Deals on Dedicated Servers - CDN
INXY

Offline

#14 2011-12-14 14:06:20

symtab
Administrator
Registered: 2010-08-23
Posts: 7,501
Website

Re: [HOWTO] Configure Lighttpd for Streaming and Hotlinking Protection

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

#15 2012-01-07 19:57:52

ful2fun.com
Member
From: Usa
Registered: 2011-09-16
Posts: 1,048
Website

Re: [HOWTO] Configure Lighttpd for Streaming and Hotlinking Protection

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.



ful2fun.com
livesexpirates.com

Offline

#16 2012-01-07 21:52:17

symtab
Administrator
Registered: 2010-08-23
Posts: 7,501
Website

Re: [HOWTO] Configure Lighttpd for Streaming and Hotlinking Protection

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

#17 2012-01-23 21:43:16

Kosimak
Member
Registered: 2012-01-19
Posts: 24
Website

Re: [HOWTO] Configure Lighttpd for Streaming and Hotlinking Protection

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

#18 2012-01-24 07:28:40

symtab
Administrator
Registered: 2010-08-23
Posts: 7,501
Website

Re: [HOWTO] Configure Lighttpd for Streaming and Hotlinking Protection

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

#19 2012-01-24 08:14:29

Kosimak
Member
Registered: 2012-01-19
Posts: 24
Website

Re: [HOWTO] Configure Lighttpd for Streaming and Hotlinking Protection

Thanks man I just sent it!

Offline

#20 2012-07-08 18:32:26

Tenche
Member
Registered: 2012-06-30
Posts: 46

Re: [HOWTO] Configure Lighttpd for Streaming and Hotlinking Protection

Kosimak wrote:

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

#21 2012-07-08 20:53:56

symtab
Administrator
Registered: 2010-08-23
Posts: 7,501
Website

Re: [HOWTO] Configure Lighttpd for Streaming and Hotlinking Protection

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

#22 2012-07-09 01:27:44

Tenche
Member
Registered: 2012-06-30
Posts: 46

Re: [HOWTO] Configure Lighttpd for Streaming and Hotlinking Protection

symtab wrote:

Comment the server.username and server.groupname with # in the lighttpd.conf file and then restart lighttpd.

Done. Works. Thanks!

Offline

#23 2012-07-09 06:40:05

Eri
Member
Registered: 2011-03-18
Posts: 977

Re: [HOWTO] Configure Lighttpd for Streaming and Hotlinking Protection

use apache streaming is more stable


Best Adult Affilitate Network:
ExoClick
Best Deals on Dedicated Servers - CDN
INXY

Offline

#24 2012-07-09 18:43:17

Tenche
Member
Registered: 2012-06-30
Posts: 46

Re: [HOWTO] Configure Lighttpd for Streaming and Hotlinking Protection

Eri wrote:

use apache streaming is more stable

No thanks. If anything, I'd switch to nginx

Offline

#25 2012-09-15 19:03:12

DuttyRock
Member
Registered: 2011-11-05
Posts: 740

Re: [HOWTO] Configure Lighttpd for Streaming and Hotlinking Protection

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

Board footer

Powered by FluxBB