nginx調優配置

#運行用戶
#user nobody;
#啓動進程,一般設置成和cpu的數量相等
worker_processes 2;
#全局錯誤日誌及PID文件
error_log E:/server/nginx-1.2.9/logs/error.log;
pid E:/server/nginx-1.2.9/logs/nginx.pid;


events {
#epoll是多路複用IO(I/O Multiplexing)中的一種方式,可是僅用於linux2.6以上內核,能夠大大提升nginx的性能
#use epoll;
worker_connections 1024;
}


http {
#設定mime類型,類型由mime.type文件定義
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 E:/server/nginx-1.2.9/logs/access.log;

sendfile on;
#tcp_nopush on;

#鏈接超時時間
#keepalive_timeout 0;
keepalive_timeout 65;
tcp_nodelay on;

#開啓gzip壓縮,文件類型爲靜態文件,類型根據實際狀況修改
gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_types text/plain application/x-javascript text/css text/javascript application/x-httpd-php image/jpeg image/gif image/png;

#設定請求緩衝
client_header_buffer_size 1k;
large_client_header_buffers 4 4k;

upstream localhost {
#根據ip計算將請求分配各那個後端tomcat,許多人誤認爲能夠解決session問題,其實並不能。
#同一機器在多網狀況下,路由切換,ip可能不一樣
#ip_hash;
server 192.168.1.104:8080;
server 192.168.1.104:8081;
}
server {
#偵聽80端口
listen 80;
server_name 192.168.1.104;

#charset koi8-r;

#access_log logs/host.access.log main;

#location / {
# root html;
# index index.jsp;
#}
location / {
proxy_connect_timeout 3;
proxy_send_timeout 30;
proxy_read_timeout 30;
proxy_pass http://localhost;
}
#error_page 404 /404.html;

# # 定義錯誤提示頁面
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
#靜態文件,nginx本身處理
location ~ ^/(images|javascript|js|css|flash|media|static)/ {
root /var/www/virtual/htdocs;
#過時30天,靜態文件不怎麼更新,過時能夠設大一點,若是頻繁更新,則能夠設置得小一點。
expires 50d;
}

# 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 ssl;
# server_name localhost;

# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;

# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;

# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;

# location / {
# root html;
# index index.html index.htm;
# }
#}

}javascript

相關文章
相關標籤/搜索