Nginx server configuration.

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

These days the content of your nginx server configuration pictures, some individual harvest to share with the world:

Nginx is currently very popular web server, it originated in russia. It has a faster processing speed, large amount of concurrent, occupy the resource advantages, especially for the static resources better, have test proved to be 30 times that of apache. It has been widely used in many portal sites, large sites, as a reverse proxy cache server, pictures etc.
This example is a combination of a feast of the blog (), the changes made.
The master station is IIS7.5 (192.168.36.70), using the.Net 3.5+ SQL 2005, for ASPX, ashx dynamic Webpage program, but the website picture server for nginx(centos 5.6,IP:192.168.33.243).


Nginx server configuration:

1.centos5.6 nginx. installed on the installation steps are as follows:


wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.00.tar.gz
tar zxvf pcre-8.00.tar.gz
cd pcre-8.00/
./configure
make && make install
cd ../

wget http://labs.frickle.com/files/ngx_cache_purge-1.0.tar.gz
tar zxvf ngx_cache_purge-1.0.tar.gz

wget http://nginx.org/download/nginx-0.8.32.tar.gz
tar zxvf nginx-0.8.32.tar.gz
cd nginx-0.8.32/
./configure --user=www --group=www --add-module=../ngx_cache_purge-1.0--prefix=/usr/local/webserver/nginx --with-http_stub_status_module--with-http_ssl_module
make && make install
cd ../

Note: to establish a WWW user and WWW user group



The 2 configuration of the nginx configuration file

Note that the nginx image server access address: 192.168.33.243:8080, nginx cache server: 192.168.33.243, so we need to configure the two web server on Nginx, so that after a cache of a, IIS master program directly call cache servers around the picture, the picture of the real server.

The configuration file is as follows:

user www www;

worker_processes 8;

error_log /usr/local/webserver/nginx/logs/nginx_error.log crit;

pid /usr/local/webserver/nginx/nginx.pid;

#Specifies the value for maximum file descriptors that can be 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;

#Note: the path to the proxy_temp_path and proxy_cache_path must be specified in the same partition
proxy_temp_path /data0/proxy_temp_dir;
#Set the Web cache name for the cache_one, the memory cache size is 200MB, 1 days have not been accessed content automatically clear, hard disk cache size is 30GB.
proxy_cache_path /data0/proxy_cache_dir levels=1:2 keys_zone=cache_one:200minactive=1d max_size=30g;

#upstream backend_server {
# server 192.168.8.43:80 weight=1max_fails=2 fail_timeout=30s;
#server 192.168.8.44:80 weight=1max_fails=2 fail_timeout=30s;
#server 192.168.8.45:80 weight=1max_fails=2 fail_timeout=30s;
#}

server //Here is the cache server
{
listen 80;
server_name 192.168.33.243,


location /
{

proxy_cache cache_one;
#Set the duration for different HTTP status code
proxy_cache_valid 200 304 12h;
#The domain name, URI, parameters are combined into the Web cache Keyvalue, according to Keyvalue Nginx; hash, storage cache content to a 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 ; //Here to jump to the real image server

log_format cache '***$time_local '

'$upstream_cache_status '

'Cache-Control: $upstream_http_cache_control '

'Expires: $upstream_http_expires '

'"$request" ($status) '

'"$http_user_agent" '; //The definition of log type (this log can display hit miss, shows whether the cache hit, the old version can default, but the new version, need to add this)

access_log /var/log/nginx/cache.log cache; //The use of the log type


expires 1d;
}

#To clear the cache, assuming a URL, the access can clear the URL cache.
location ~ /purge(/.*)
{
#Settings allow only IP or IP segment specified can clear the URL cache.
allow 127.0.0.1;
allow 192.168.0.0/16;
deny all;
proxy_cache_purge cache_one $host$1$is_args$args;
}

#Extension to dynamic application.Php,.Jsp,.Cgi at the end of the no cache.
location ~ .*\.(php|jsp|cgi)?$
{
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://backend_server;
}

access_log off;
}

server//The real picture server

{

Listen 8080;

Server_name 192.168.33.243;

Location /

{

root /images/;

}

access_log /***/***combined; //Access log, generally off.

}
}


So far, the image server can access the build success







Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Ernest at February 01, 2014 - 9:02 PM