1. Halo Guest, pastikan Anda selalu menaati peraturan forum sebelum mengirimkan post atau thread baru.

Hotlink Protection bikin CPU resource meninggi?

Discussion in 'Pemrograman Web' started by siprof, Feb 26, 2013.

  1. siprof

    siprof Reviewer

    Joined:
    Jun 4, 2011
    Messages:
    845
    Likes Received:
    28
    Ok seharusnya Hotlink Protection tidak membuat CPU resource meninggi, namun ini pengalaman ane:

    Pertama ane kasih pesan error 403 forbidden hasilnya: ane pernah disuspend oleh web hosting pertama ane, sehingga ane terpaksa pindah hosting lalu di web hosting kedua database MySQL web ane berulah terus kadang gagal konek (ada hubungannya ga ya?). Ane cek di forum2, MySQL yang sering gagal konek pertanda hostingnya sibuk banget alias CPU resource meninggi. Ane cek di resource usage log masih dibawah 25% tuh?

    Hotlink Protection dengan 403 Forbidden Message
    Code:
    # BEGIN Hotlink Protection
    # based on http://perishablepress.com/creating-the-ultimate-htaccess-anti-hotlinking-strategy/
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g?|png|swf)$ [NC]
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?websitegue\. [NC]
    RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?facebook\. [NC]
    RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?twitter\. [NC]
    RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?nrelate\. [NC]
    RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?outbrain\. [NC]
    RewriteCond %{HTTP_REFERER} !google\. [NC]
    RewriteCond %{HTTP_REFERER} !bing\. [NC]
    RewriteCond %{HTTP_REFERER} !yahoo\. [NC]
    RewriteCond %{HTTP_USER_AGENT} !googlebot [NC]
    RewriteCond %{HTTP_USER_AGENT} !msnbot [NC]
    RewriteCond %{HTTP_USER_AGENT} !slurp [NC]
    RewriteRule \.(gif|jpe?g?|png|swf)$ - [F,NC,L]
    </ifModule>
    # END Hotlink Protection

    Kedua ane ganti dengan reroute ke gambar vector .svg (alasannya gambar vector berapapun resolusinya tetap mulus ga pecah). Hasilnya MySQL yg biasanya muncul pesan error_log skrg udah kaga lagi. (sekali lagi ada hubungannya ga ya?)

    Hotlink Protection dengan Reroute ke Gambar
    Code:
    # BEGIN Hotlink Protection
    # based on http://perishablepress.com/creating-the-ultimate-htaccess-anti-hotlinking-strategy/
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g?|png|swf)$ [NC]
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?websitegue\. [NC]
    RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?facebook\. [NC]
    RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?twitter\. [NC]
    RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?nrelate\. [NC]
    RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?outbrain\. [NC]
    RewriteCond %{HTTP_REFERER} !google\. [NC]
    RewriteCond %{HTTP_REFERER} !bing\. [NC]
    RewriteCond %{HTTP_REFERER} !yahoo\. [NC]
    RewriteCond %{HTTP_USER_AGENT} !googlebot [NC]
    RewriteCond %{HTTP_USER_AGENT} !msnbot [NC]
    RewriteCond %{HTTP_USER_AGENT} !slurp [NC]
    RewriteRule \.(gif|jpe?g?|png|swf)$ http://www.websitegue.com/nohotlinking.svg [R,NC,L]
    </ifModule>
    # END Hotlink Protection

    Btw mungkin ada agan2 yg memiliki pengalaman serupa?
     
  2. ilham33

    ilham33 Trusted Web Hosting

    Joined:
    Feb 16, 2010
    Messages:
    2,785
    Likes Received:
    227
    Location:
    The North |
    kalo forbiden itu krn domain km tdk di masukkan kdalam whitelist.
    pastikan kalau memakai hotlink protection domain dgn www. dan tanpa www d masukkan ke whitelist yg dperbolehkan.
     
  3. siprof

    siprof Reviewer

    Joined:
    Jun 4, 2011
    Messages:
    845
    Likes Received:
    28
    bukan begitu maksud ane gan...
    maksud ane situs lain yg mau nyolong ane kasih tampilan 403 forbiden alias gambar kaga nongol di situs yg nyolong
    Code:
    RewriteRule \.(gif|jpe?g?|png|swf)$ - [F,NC,L]
    tanda - dibarengi kode F artinya kurang lebih berikan pesan error [F]orbidden

    btw ane udah whitelist website ane kok :)
    Code:
    RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?websitegue\. [NC]
    nah balik ke pertanyaan ane, apa bener memberikan 403 Forbidden message bisa bikin CPU resource meninggi?
     
  4. ilham33

    ilham33 Trusted Web Hosting

    Joined:
    Feb 16, 2010
    Messages:
    2,785
    Likes Received:
    227
    Location:
    The North |
    saya pikir bukan krn itu,yg memberatkan itu biasanya di proses mysql dan php.coba optimasi mysql dan disable smua plugin kalo pake wp
     
  5. xrvel

    xrvel Super Hero

    Joined:
    Oct 21, 2007
    Messages:
    2,873
    Likes Received:
    947
    Location:
    Di sini
    kalo analisa saya :
    kalo yg hotlink ada 1jt view / day, berarti hampir sama dgn server kita dapat visitor 1jt view / day >> kalo server nggak kuat, ya cpu nya naek.
    saran saya pake cloudflare jadi file svg itu kesimpen di cachenya cloudflare & request tidak dihandle server kita.
    (cloudflare kalo nggak salah jg punya hotlink protection CMIIW)
     
  6. desiredlash

    desiredlash Super Hero

    Joined:
    Jun 23, 2011
    Messages:
    2,747
    Likes Received:
    86
    ngomong2 kalo image dihotlink gak bekalan ke index ya?

    ane dah praktek pake plugin om ewwink n htacess..

    yg lain gimana ya.
    kalo masalah cpu usage emang ningkat gan.. :(
     
  7. mp3online

    mp3online Super Hero

    Joined:
    Jul 19, 2011
    Messages:
    2,228
    Likes Received:
    294
    Location:
    jakarta
    itu bisa nungul 403 kan kalau url imagenya ditulis langsung ke adress bar boss.
    tapi kalau diload pake html tag img ya gak nungul apa2 lah
     
  8. articlegig

    articlegig Hero

    Joined:
    Oct 20, 2010
    Messages:
    689
    Likes Received:
    37
    Location:
    Surabaya
    wah kebetulan ane lagi belajar ini.. menyimak..
     
  9. khoid

    khoid Super Hero

    Joined:
    Aug 18, 2008
    Messages:
    3,380
    Likes Received:
    256
    Location:
    depok
    cuma logika ane aja nih om,,,

    klo 403 forbiden berarti secara ga langsung itu ada yg akses ke web/folder/file dikau (kasus dikau hotlink image) ya klo cuma 1 ato 2 kunjungan dari hotlink sih ga masslah, cuma bener kata om xrvel klo hotlink na ada view bnyak, ya berarti request ke host dikau banyak jg,,, yg bikin CPU resource naek mungkin dari hasil write ke file error log dan access log host dikau,,. pas ente ganti ke file nohotlinking.svg server cuma write ke file access log (ini asumsi klo access log sama error log dikau aktip yak)

    dari pada ribet2, mending file nohotlinking.svg dikau upload ke free image host,, jadi hotlink na diarahin ke image host :swt2: klo file nohotlinking.svg tetep di server dikau ya tetep aja nanggung resource sama bandwith :D
     
  10. mp3online

    mp3online Super Hero

    Joined:
    Jul 19, 2011
    Messages:
    2,228
    Likes Received:
    294
    Location:
    jakarta
    lebih baik hotlink proteksinya dilenpar ke image yg ada di beda server, atau lempar aja ke picasa :)
    tapi kalau yg niat hotkink bener2 nekat sih tetep bisa dicolong :D
     
  11. siprof

    siprof Reviewer

    Joined:
    Jun 4, 2011
    Messages:
    845
    Likes Received:
    28
    Makanya ane izinkan Google, Bing, dan Yahoo! crawling situs ane gan, silaken cek lagi script ane di atas :)

    dikutip dari Wikipedia: "A web server may return a 403 Forbidden HTTP status code in response to a request from a client for a web page or resource to indicate that the server refuses to allow the requested action. In other words, the server can be reached, but the server declined to allow the requested access."

    Jadi IMO, 403 ga mesti nongolin pesan error gan, intinya si B ga dpt data dari si A...


    Nah sama gan, ane juga menduga begitu, cuman ane belum bisa membuktikan mungkin nanti pake website dummy ane :)
     

Share This Page