
1 反向代理准备两台nginx服务器nginx01的服务器部署静态网站nginx02配置方向代理以及防盗链nginx01在/www/www下准备静态文件 index.html 以及在/www/www/static/ 准备css img js worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #log_format main $remote_addr - $remote_user [$time_local] $request # $status $body_bytes_sent $http_referer # $http_user_agent $http_x_forwarded_for; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 80; server_name localhost; location / { root /www/www; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location /50x.html { root html; } } }nginx02location / { proxy_pass http://192.168.65.101; root /www/www; index www.html index.htm; }实验结果2 配置防盗链nginx01location / { # 检测referers是否为101不是则返回403 valid_referers 192.168.65.101; if ($invalid_referer){ return 403; } root /www/www; index index.html index.htm; }实验结果ps valid_referers none 检测Referer头域不存在的情况也可以访问