Nginx under Image Server configuration

Source: Internet
Author: User

#user nobody;

Worker_processes 8;


#error_log Logs/error.log;

#error_log Logs/error.log Notice;

#error_log Logs/error.log Info;


#pid Logs/nginx.pid;


#Specifies the value for maximum file descriptors the can is opened by thisprocess.

Worker_rlimit_nofile 65535;


Events {

Use Epoll;

Worker_connections 65535;

}


HTTP {

Include Mime.types;

Default_type Application/octet-stream;


CharSet Utf-8;

Server_names_hash_bucket_size 128;

Client_header_buffer_size 32k;

Large_client_header_buffers 4 32k;

Client_max_body_size 300m;

Sendfile on;

Tcp_nopush on;

Keepalive_timeout 60;

Tcp_nodelay on;

Client_body_buffer_size 512k;

Proxy_connect_timeout 5;

Proxy_read_timeout 60;

Proxy_send_timeout 5;

Proxy_buffer_size 16k;

Proxy_buffers 4 64k;

Proxy_busy_buffers_size 128k;

Proxy_temp_file_write_size 128k;

gzip on;

Gzip_min_length 1k;

Gzip_buffers 4 16k;

Gzip_http_version 1.1;

Gzip_comp_level 2;

Gzip_types text/plainapplication/x-javascript text/css Application/xml;

Gzip_vary on;

#注: The path specified by Proxy_temp_path and Proxy_cache_path must be in the same partition

Proxy_temp_path/data02/proxy_temp_dir;

#设置Web缓存区名称为cache_one, the size of the memory cache is automatically cleared for content that is not accessed for 200mb,1 days, and the disk cache space size is 5GB.

Proxy_cache_path/data02/proxy_cache_dir levels=1:2 keys_zone=cache_one:200m inactive=1d max_size=5g;


Log_format Cache ' * * * $time _local '

' $upstream _cache_status '

' Cache-control: $upstream _http_cache_control '

' Expires: $upstream _http_expires '

' $request ' ($status) '

' $http _user_agent '; #定义日志格式 (this log format can show hit miss and so on, showing whether the cache is hitting, the old version by default, but the new version, found to add this)

Server #此处为缓存服务器

{


Listen 8089;

server_name SPIDER. Ykbdas;

Location/

{

Proxy_cache Cache_one;

#对不同的HTTP状态码设置不同的缓存时间

Proxy_cache_valid 304 12h;

#以域名, URI, parameters are combined into the Web cache key value, Nginx based on the key value hash, storage cache content in the level two cache directory

Proxy_cache_key $host $uri$is_args$args;

Proxy_set_header Host $host;

Proxy_set_header x-forwarded-for $remote _addr;

Proxy_pass http://172.33.11.7:8080; #此处跳转到真实的图片服务器



Access_log/home/spider/spider_nginx/nginx/logs/cache.log Cache; #使用这个日志格式


Expires 1d;

}

#用于清除缓存, assuming that a URL is http://192.168.8.42/test.txt, you can clear the cache of the URL by accessing Http://192.168.8.42/purge/test.txt.


Location ~/purge (/.*)

{

#设置只允许指定的IP或IP段才可以清除URL缓存.

Allow 127.0.0.1;

Deny all;

#proxy_cache_purge Cache_one$host$1$is_args$args;

}


Dynamic applications that end in #扩展名以. PHP,. JSP,. CGI are not cached.

Location ~. *\. (php|jsp|cgi)? $

{

Proxy_set_header Host $host;

Proxy_set_header x-forwarded-for $remote _addr;

}


Access_log off;

}


#真实的图片服务器

Server

{

Listen 8080;

server_name SPIDER. Ykbdas;

Location/

{

Root/data02/spider;

}


Access_log/home/spider/spider_nginx/nginx/logs/nginx_access.log;

}


}


This article is from the "System operation and maintenance website Development" blog, please be sure to keep this source http://cgc888.blog.51cto.com/3989433/1688455

Nginx Patch Server Configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.