location ~ \.mp4($|/) {
return 301 http://google.com;
allow 118.70.170.88;
deny all;
}
- https://distinctplace.com/2017/04/17/nginx-access-control-allow-origin-cors/
- https://www.digitalocean.com/community/tutorials/how-to-create-temporary-and-permanent-redirects-with-apache-and-nginx
- https://serverfault.com/questions/832975/nginx-block-access-to-url
if ($http_user_agent ~* (wget|curl|Lavf) ) {
return 202;
}
Liệt kê danh sách referer không được phép (bên ngoài block server)
map $http_referer $bad_referer {
hostnames;
default 0;
# Put regexes for undesired referers here
"~hoang1.com" 1;
"~hoang2.net" 1;
"~hoang3.vn" 1;
}
Thêm phần cấu hình từ chối:
if ($bad_referer) {
return 200;
}
- http://nginx.org/en/docs/http/ngx_http_referer_module.html
- https://stackoverflow.com/questions/24105799/nginx-block-from-referrer
<IfModule mod_rewrite.c>
RewriteRule (\.html)$ - [F,L,NC]
</IfModule>
- https://stackoverflow.com/questions/16108399/deny-access-to-specific-file-types-in-specific-directory
- https://stackoverflow.com/questions/11728976/how-to-deny-access-to-a-file-in-htaccess
location ^~ /.well-known/acme-challenge/ {
default_type "text/plain";
rewrite /.well-known/acme-challenge/(.*) /$1 break;
root /usr/share/nginx/html;
}
-> Include vào mỗi VirtualHost