Nginx图片服务器配置简单示例
时间:2014-06-26 00:13 来源:linux.it.net.cn 作者:IT网
公司图片Windows服务机器准备迁移到Linux,约有公司 2.8KW 张零碎图片 1.8T 文件占有量。
Nginx 带动整个公司核新图片业务,I/0 老高,访问速度龟速,上头给俺的任务就是立马先搞定龟速问题。
花了一小天的时间搞好所有nginx 配置 速度快了几倍,配置如下:
复制代码代码示例:
events {
worker_connections 65535;
use epoll;
}
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;
access_log off;
charset utf-8;
keepalive_timeout 60;
sendfile off;
tcp_nopush off;
client_header_buffer_size 8k;
large_client_header_buffers 8 128k;
client_max_body_size 300m;
client_body_buffer_size 2048k;
gzip off;
server {
server_name _;
# rewrite (.*)$ /opt/nginx/html/404.html?;
return 404;
error_page 404 = /opt/nginx/html/404.html;
}
include nginx-upload.conf;
server
{
listen 80;
server_name file.xxx.com;
root /usr/local/wwwweb/file.xxx.com;
#access_log /opt/nginx/logs/file.xxx.com;
access_log off;
location ~ .*\.(gif|jpg|jpeg|png)$ {
root /usr/local/wwwweb/file.xxxx.com;
#if ( !-f request_name ) {
if ( $status = 404 ) {
rewrite /(.*)\.jpg /$1.JPG;
rewrite /(.*)\.JPG /$1.jpg;
}
}
}
}
(责任编辑:IT)
公司图片Windows服务机器准备迁移到Linux,约有公司 2.8KW 张零碎图片 1.8T 文件占有量。
复制代码代码示例:
events {
(责任编辑:IT)worker_connections 65535; use epoll; } 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; access_log off; charset utf-8; keepalive_timeout 60; sendfile off; tcp_nopush off; client_header_buffer_size 8k; large_client_header_buffers 8 128k; client_max_body_size 300m; client_body_buffer_size 2048k; gzip off; server { server_name _; # rewrite (.*)$ /opt/nginx/html/404.html?; return 404; error_page 404 = /opt/nginx/html/404.html; } include nginx-upload.conf; server { listen 80; server_name file.xxx.com; root /usr/local/wwwweb/file.xxx.com; #access_log /opt/nginx/logs/file.xxx.com; access_log off; location ~ .*\.(gif|jpg|jpeg|png)$ { root /usr/local/wwwweb/file.xxxx.com; #if ( !-f request_name ) { if ( $status = 404 ) { rewrite /(.*)\.jpg /$1.JPG; rewrite /(.*)\.JPG /$1.jpg; } } } } |