0

I'm using nginx to serve static files for my website.

I'm trying to protect my static files from hotlinking, so I've done this:

location ~*.(gif|jpg|jpeg|png|bmp|swf)$ {
  valid_referers none blocked mywebsite.com *.mywebsite.com ;
   }

However, this has stopped my static files from being served from other websites and from my website. My website is a white page now. Any ideas?

Dominic Rodger
  • 97,747
  • 36
  • 197
  • 212
zzlettle
  • 353
  • 1
  • 6
  • 17
  • Is your HTML loading OK? What do your nginx logs say? – Dominic Rodger Aug 12 '14 at 09:56
  • yes html and css js ok ,ngins say 404 for images files – zzlettle Aug 12 '14 at 11:21
  • What do your log files say? – Dominic Rodger Aug 12 '14 at 11:25
  • 2014/08/12 12:01:21 [error] 3442#0: *2 open() "/usr/share/nginx/html/static/images/bg_content.png" failed (2: No such file or directory), client: 27.28.126.153, server: fanhuaxiu.com, request: "GET /static/images/bg_content.png HTTP/1.1", host: "fanhuaxiu.com", referrer: "http://fanhuaxiu.com/static/css/style.css" – zzlettle Aug 12 '14 at 12:08
  • Does `/usr/share/nginx/html/static/images/bg_content.png` exist? – Dominic Rodger Aug 12 '14 at 12:10
  • 27.28.126.153 - - [12/Aug/2014:12:01:22 +0000] "GET /static/images/bg_footer.png HTTP/1.1" 404 169 "http://fanhuaxiu.com/static/css/style.css" "Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Firefox/31.0" "-" – zzlettle Aug 12 '14 at 12:10
  • yes of cause it exit,when i remove this code from nginx ,my website show all the images – zzlettle Aug 12 '14 at 12:12
  • i means the images in the django folder which not /usr/share/nginx/html/static/images/bg_content.png ,it is indeed here /django project/mywebsite/static/bg_content.png – zzlettle Aug 12 '14 at 12:15

0 Answers0