2019独角兽企业重金招聘Python工程师标准>>>
- 语法
Syntax: valid_referers none | blocked | server_names | string ...; Default: -- Context:server,location
- 例/etc/nginx/conf.d/default.conf
server { listen 80; server_name localhost; sendfile on; #charset koi8-r; access_log /var/log/nginx/log/static_access.log main; location ~ .*\.(jpg|gif|png)$ { valid_referers none blocked 192.168.0.106 www.baidu.com; if ($invalid_referer) { return 403; } root /opt/app/code/images; }
- 命令curl -I http://localhost/wei.png
[root@promote conf.d]# curl -I http://localhost/wei.png HTTP/1.1 200 OK Server: nginx/1.14.0 Date: Sat, 18 Aug 2018 13:13:09 GMT Content-Type: image/png Content-Length: 244044 Last-Modified: Tue, 08 Aug 2017 09:17:25 GMT Connection: keep-alive ETag: "598981a5-3b94c" Accept-Ranges: bytes
-
命令curl -e "http://www.baidu.com" -I http://localhost/wei.png
[root@promote conf.d]# curl -e "http://www.baidu.com" -I http://localhost/wei.png HTTP/1.1 200 OK Server: nginx/1.14.0 Date: Sat, 18 Aug 2018 13:09:37 GMT Content-Type: image/png Content-Length: 244044 Last-Modified: Tue, 08 Aug 2017 09:17:25 GMT Connection: keep-alive ETag: "598981a5-3b94c" Accept-Ranges: bytes
-
命令curl -e "http://www.google.com" -I http://localhost/wei.png
[root@promote conf.d]# curl -e "http://www.google.com" -I http://localhost/wei.png HTTP/1.1 403 Forbidden Server: nginx/1.14.0 Date: Sat, 18 Aug 2018 13:12:52 GMT Content-Type: text/html Content-Length: 169 Connection: keep-alive
-
命令curl -e "http://192.168.0.106" -I http://localhost/wei.png
[root@promote conf.d]# curl -e "http://192.168.0.106" -I http://localhost/wei.png HTTP/1.1 200 OK Server: nginx/1.14.0 Date: Sat, 18 Aug 2018 12:58:27 GMT Content-Type: image/png Content-Length: 244044 Last-Modified: Tue, 08 Aug 2017 09:17:25 GMT Connection: keep-alive ETag: "598981a5-3b94c" Accept-Ranges: bytes