nginx 프로필 예

8094 단어 nginx

첫 번 째 설정
 nginx 업로드 최대 1M 로 제한 되 며, 업로드 파일 기능 이 있 으 면 업로드 최대 값 을 수정 하 십시오.
 
 
#user  nobody;
worker_processes  1;
 
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
 
#pid        logs/nginx.pid;
 
 
events {
    worker_connections  1024;
}
 
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;
 
    sendfile        on;
    #tcp_nopush     on;
 
    #keepalive_timeout  0;
    keepalive_timeout  65;
 
    #gzip  on;
    
    #    domain
    
 
    upstream baidu{
ip_hash;
server 127.0.0.1:8088; # 
    }
 
    #---    start---
server{
        listen  80;
        charset utf-8;
        #access_log  logs/access.www.baidu.com.log;
 
        location / {
                proxy_pass              http://baidu;
                proxy_buffer_size 64k;
                proxy_buffers 4 64k;
                proxy_redirect    off;
                proxy_set_header  Host $host;
                proxy_set_header  X-Real-IP  $remote_addr;
                proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
        }
 
        error_page  404              /404.htm;
 
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
#                   “proxy_pass”->upstream                 
       server_name www.baidu.com;
       #error_log logs/error.www.baidu.com.log;
    }
 
    #---    end---
 
 
 
    #server {
        #listen       80;
        #server_name  localhost;
 
        #charset koi8-r;
 
        #access_log  logs/host.access.log  main;
 
        #location / {
            #root   html;
            #index  index.html index.htm index.jsp;
        #}
 
        #error_page  404              /404.html;
 
        # redirect server error pages to the static page /50x.html
        #
        #error_page   500 502 503 504  /50x.html;
        #location = /50x.html {
            #root   html;
        #}
 
        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}
 
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}
 
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    #}
 
 
    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;
 
    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
 
 
    # HTTPS server
    #
    #server {
    #    listen       443;
    #    server_name  localhost;
 
    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;
 
    #    ssl_session_timeout  5m;
 
    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers   on;
 
    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
 
}

 
 
 
두 번 째 설정 (인터넷 에서 추출)
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 this process.   
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/plain application/x-javascript text/css application/xml;   
gzip_vary on;   
 
# :proxy_temp_path proxy_cache_path               
proxy_temp_path /data0/proxy_temp_dir;   
#  Web      cache_one,         200MB,1       ,         30GB。   
proxy_cache_path /data0/proxy_cache_dir levels=1:2 keys_zone=cache_one:200m inactive=1d max_size=30g;   
 
upstream backend_server {   
server 192.168.8.43:80 weight=1 max_fails=2 fail_timeout=30s;   
server 192.168.8.44:80 weight=1 max_fails=2 fail_timeout=30s;   
server 192.168.8.45:80 weight=1 max_fails=2 fail_timeout=30s;   
}   
 
server   
{   
listen 80;   
server_name www.yourdomain.com 192.168.8.42;   
index index.html index.htm;   
root /data0/htdocs/www;   
 
location /   
{   
#          502、504、       ,        upstream             ,      。   
proxy_next_upstream http_502 http_504 error timeout invalid_header;   
proxy_cache cache_one;   
#    HTTP               
proxy_cache_valid 200 304 12h;   
#   、URI、     Web   Key ,Nginx  Key   ,                 
proxy_cache_key $host$uri$is_args$args;   
proxy_set_header Host $host;   
proxy_set_header X-Forwarded-For $remote_addr;   
proxy_pass http://backend_server;   
expires 1d;   
}   
 
#      ,    URL http://192.168.8.42/test.txt,    http://192.168.8.42/purge/test.txt      URL   。   
location ~ /purge(/.*)   
{   
#        IP IP      URL  。   
allow 127.0.0.1;   
allow 192.168.0.0/16;   
deny all;   
proxy_cache_purge cache_one $host$1$is_args$args;   
}   
 
#    .php、.jsp、.cgi            。   
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;   
}   
}   

 

좋은 웹페이지 즐겨찾기