nginx关于服务静态文件的配置
我们的目标是配置一个服务最快且cpu/io利用最有效的服务器,更重要的是一个安全的web服务器,下面的配置文件适用于最新版nginx. 写道 ####################################################### ### Calomel.org /etc/nginx.conf BEGIN ####################################################### # pid /var/run/nginx.pid; user nginx nginx; worker_processes 2; events { worker_connections 1024; } http { ## MIME types include mime.types; # types { # image/gif gif; # image/jpeg jpg; # image/png png; # image/bmp bmp; # image/x-icon ico; # text/css css; # text/html html; # text/plain bob; # text/plain txt; } default_type application/octet-stream; ## Size Limits client_body_buffer_size 8k; client_header_buffer_size 1k; client_max_body_size 1k; large_client_header_buffers 1 1k; ## Timeouts client_body_timeout 5; client_header_timeout 5; keepalive_timeout 5 5; send_timeout 5; ## General Options ignore_invalid_headers on; limit_zone gulag $binary_remote_addr 1m; recursive_error_pages on; sendfile on; server_name_in_redirect off; server_tokens off; ## TCP options tcp_nodelay on; tcp_nopush on; ## Compression gzip on; gzip_static on; gzip_buffers 16 8k; gzip_comp_level 9; gzip_http_version 1.0; gzip_min_length 0; gzip_types text/plain text/html text/css image/x-icon image/bmp; gzip_vary on; ## Log Format log_format main ''$remote_addr $host $remote_user [$time_local] "$request" '' ''$status $body_bytes_sent "$http_referer" "$http_user_agent" "$gzip_ratio"''; ## Deny access to any host other than (www.)mydomain.com server { server_name _; #default 拥有帝国一切,皆有可能。欢迎访问phome.net return 444; } ## Server (www.)mydomain.com server { access_log /var/log/nginx/access.log main buffer=32k; error_log /var/log/nginx/error.log info; expires 31d; limit_conn gulag 5; listen 127.0.0.1:8080 rcvbuf=64k backlog=128; root /disk01/htdocs; server_name mydomain.com www.mydomain; ## SSL Options (only enable if you use a SSL certificate) # ssl on; # ssl_certificate /ssl_keys/mydomain.com_ssl.crt; # ssl_certificate_key /ssl_keys/mydomain_ssl.key; # ssl_ciphers HIGH:!ADH:!MD5; # ssl_prefer_server_ciphers on; # ssl_protocols SSLv3; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; ## Only allow GET and HEAD request methods if ($request_method !~ ^(GET|HEAD)$ ) { return 444; }
## Deny illegal Host headers if ($host !~* ^(mydomain.com|www.mydomain.com)$ ) { return 444; } ## Deny certain User-Agents (case insensitive) ## The ~* makes it case insensitive as opposed to just a ~ if ($http_user_agent ~* (Baiduspider|Jullo) ) { r |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |