Prevent pictures from being stolen and wasting traffic under LNMP

888u

Last update at :2024-05-20,Edit by888u

Generally speaking, the traffic of our server or VPS has a certain limit. Some pictures on our website may be the main source of traffic consumption. If the picture resources are stolen by people, the loss of our resources will be huge. of. Here is a simple way to deal with the problem of image theft in the LNMP environment:

  • server {
  • listen 80;
  • server_name demo.neoease.com;
  • index index.html index.htm index.php;
  • root /var/www/demo_neoease_com;
  •         # Add an expiration time of 1 year to the image here, and prohibit Google, Baidu and websites other than this site from quoting the image
  • location ~ .*\.(ico|jpg|jpeg|png|gif)$ {
  • expires 1y;
  • valid_referers none blocked demo.neoease.com *.google.com *.baidu.com;
  •                   if ($invalid_referer) {
  • return 404;
  •             }
  • }
  • log_format demo.neoease.com ‘$remote_addr – $remote_user [$time_local] $request’
  • ‘$status $body_bytes_sent $http_referer ‘
  • ‘$http_user_agent $http_x_forwarded_for’;
  • access_log /var/log/demo.neoease.com.log demo.neoease.com;
  • }
  • Recommended site search: European server, independent IP virtual host, American virtual host, free cloud host, foreign vps server rental, mainland China registration-free host, dynamic vps instant IP change, domain name space agent, mainland China registration-free host, Domain name registration website query,

    Prevent pictures from being stolen and wasting traffic under LNMP

    All copyrights belong to 888u unless special state
    取消
    微信二维码
    微信二维码
    支付宝二维码