Nginx mp4热链接保护不起作用

Nginx mp4热链接保护不起作用,nginx,Nginx,我正在尝试阻止我的mp4与nginx“有效的\u引用者”的热链接: 但它根本不起作用,mp4仍然显示在窃取视频的网站上,如果我把一些随机域而不是“mysite.com”,视频仍然有效 如果有帮助,以下是我的服务器配置文件: server { listen 80; server_name dl.mysite.com; root /home/videos; index index.php index.html; autoindex off;

我正在尝试阻止我的mp4与nginx“有效的\u引用者”的热链接:

但它根本不起作用,mp4仍然显示在窃取视频的网站上,如果我把一些随机域而不是“mysite.com”,视频仍然有效

如果有帮助,以下是我的服务器配置文件:

server {
    listen   80;
    server_name dl.mysite.com;
    root /home/videos;

    index index.php index.html;

    autoindex off; 

    location ~ /\. {
        deny all;
    }

    # serve static files directly
    location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
        access_log off;
        expires max;
    }

    # streaming
    location ~ \.mp4$ {

        valid_referers none blocked mysite.com;
        if ($invalid_referer) {
            return   403;
        }

        gzip off;
        gzip_static off;

        mp4;
        mp4_buffer_size 1M;
        mp4_max_buffer_size 300M;
    }

    location ~ .flv$ {
        flv;
    }

    # removes trailing slashes
    if (!-d $request_filename)
    {
        rewrite ^/(.+)/$ /$1 permanent;
    }


    # canonicalize codeigniter url end points
    if ($request_uri ~* ^(/lobby(/index)?|/index(.php)?)/?$)
    {
        rewrite ^(.*)$ / permanent;
    }

    # removes trailing "index" from all controllers
    if ($request_uri ~* index/?$)
    {
        rewrite ^/(.*)/index/?$ /$1 permanent;
    }

    # unless the request is for a valid file (image, js, css, etc.), send to bootstrap
    if (!-e $request_filename)
    {
        rewrite ^/(.*)$ /index.php?/$1 last;
        break;
    }

    # catch all
    error_page 404 /index.php;

        location ~ \.php$ {
        try_files $uri =404;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_read_timeout 600;
                include fastcgi_params;
        }

}

我做错了什么?

我过去也有同样的问题。我以为它不起作用,但实际上,它起作用了。只要确保你不允许任何人,除了你


有时leechers会尝试使用null或空的referer来绕过这个问题,但没有可能的解决方案。我可以建议一种可能的解决方案来阻止资源目录。看,这个人用一种简单的方式解释了一切。

我过去也有过同样的问题。我以为它不起作用,但实际上,它起作用了。只要确保你不允许任何人,除了你

有时leechers会尝试使用null或空的referer来绕过这个问题,但没有可能的解决方案。我可以建议一种可能的解决方案来阻止资源目录。看,这个人用一种简单的方式解释了一切

server {
    listen   80;
    server_name dl.mysite.com;
    root /home/videos;

    index index.php index.html;

    autoindex off; 

    location ~ /\. {
        deny all;
    }

    # serve static files directly
    location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
        access_log off;
        expires max;
    }

    # streaming
    location ~ \.mp4$ {

        valid_referers none blocked mysite.com;
        if ($invalid_referer) {
            return   403;
        }

        gzip off;
        gzip_static off;

        mp4;
        mp4_buffer_size 1M;
        mp4_max_buffer_size 300M;
    }

    location ~ .flv$ {
        flv;
    }

    # removes trailing slashes
    if (!-d $request_filename)
    {
        rewrite ^/(.+)/$ /$1 permanent;
    }


    # canonicalize codeigniter url end points
    if ($request_uri ~* ^(/lobby(/index)?|/index(.php)?)/?$)
    {
        rewrite ^(.*)$ / permanent;
    }

    # removes trailing "index" from all controllers
    if ($request_uri ~* index/?$)
    {
        rewrite ^/(.*)/index/?$ /$1 permanent;
    }

    # unless the request is for a valid file (image, js, css, etc.), send to bootstrap
    if (!-e $request_filename)
    {
        rewrite ^/(.*)$ /index.php?/$1 last;
        break;
    }

    # catch all
    error_page 404 /index.php;

        location ~ \.php$ {
        try_files $uri =404;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_read_timeout 600;
                include fastcgi_params;
        }

}