nginx.conf文件内容:
#作者:杨志永
#日期:2012-8-30
#Email: ljy520zhiyong@163.com
#如果你的是Linux或Unix系统,则将下面的注释去掉
#user nobody;
#将下面的4改为你CPU的核心数
worker_processes 4;
#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 {
# mime.types 表示允许的文件类型
include mime.types;
default_type application/octet-stream;
# inluce proxy.conf 表示加入代理设置文件
include proxy.conf;
#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;
server {
#默认监听端口
listen 80;
# 服务器的名字
server_name localhost;
#字符编码,建议为utf-8
charset utf-8;
#access_log logs/host.access.log main;
# 此处是关键,设置代理服务器将以JSP结尾和do,action结尾的后缀名文件转交给Tomcat来处理
location ~ .*.[jsp|do|action]$ {
#root H:\server\apache-tomcat-6.0.35\webapps\ROOT;
# 下面的代表的是Tomcat服务器的地址和端口
proxy_pass http://127.0.0.1:8080;
}
location / {
# 这里的root设置为你的web应用程序的路径
root H:\server\apache-tomcat-6.0.35\webapps\ROOT;
index yang.jsp index.html index.htm;
}
#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;
# }
#}
}
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; #获取真实IP
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #获取代理者的真实ip
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;