nginx关于服务静态文件的配置
eturn 444;
} ## Deny certain Referers (case insensitive) ## The ~* makes it case insensitive as opposed to just a ~ if ($http_referer ~* (babes|click|diamond|forsale|girl|jewelry|love|nudit|organic|poker|porn|poweroversoftware|sex|teen|video|webcam|zippo) ) { return 444; } ## Redirect from www to non-www if ($host = ''www.mydomain.com'' ) { rewrite ^/(.*)$ http://mydomain.com/$1 permanent; } ## Stop Image and Document Hijacking location ~* (\.jpg|\.png|\.css)$ { if ($http_referer !~ ^(http://mydomain.com) ) { return 444; } } ## Restricted Access directory location ^~ /secure/ { allow 127.0.0.1/32; allow 10.10.10.0/24; deny all; auth_basic "RESTRICTED ACCESS"; auth_basic_user_file /var/www/htdocs/secure/access_list; 拥有帝国一切,皆有可能。欢迎访问phome.net } ## Only allow these file types to document root location / { if ($request_uri ~* (^\/|\.html|\.jpg|\.org|\.png|\.css|favicon\.ico|robots\.txt)$ ) { break; } return 444; } ## Serve an empty 1x1 gif _OR_ an error 204 (No Content) for favicon.ico location = /favicon.ico { #empty_gif; return 204; } ## System Maintenance (Service Unavailable) if (-f $document_root/system_maintenance.html ) { error_page 503 /system_maintenance.html; return 503; } ## All other errors get the generic error page error_page 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 500 501 502 503 504 505 /error_page.html; location /error_page.html { internal; } } } # ####################################################### ### Calomel.org /etc/nginx.conf END ####################################################### 2. nginx关于对后端服务器的反向代理配置 有三个后端服务,一个为web内容服务,一个是论坛服务,一个为文件服务. 当一个请求来时,nginx代理服务器其查看url把请求定向到相应的服务器,这个配置也缓冲文件服务的内容,但是论坛的和数据下载的内容就不缓存了,这个配置也使用了压缩,更好的节省内存 写道 ####################################################### ### Calomel.org /etc/nginx.conf BEGIN ####################################################### pid /var/run/nginx.pid; user nginx nginx; worker_processes 10; events { worker_connections 1024; } http { ## MIME types #include /etc/nginx_mime.types; default_type application/octet-stream; ## Size Limits client_body_buffer_size 128K; client_header_buffer_size 128K; client_max_body_size 1M; large_client_header_buffers 1 1k; ## Timeouts 拥有帝国一切,皆有可能。欢迎访问phome.net client_body_timeout 60; client_header_timeout 60; expires 24h; keepalive_timeout 60 60; send_timeout 60; ## General Options ignore_invalid_headers on; keepalive_requests 100; limit_zone gula |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |