百度百科说:

Nginx ("engine x") 是一个高性能的HTTP反向代理服务器,也是一个IMAP/POP3/SMTP服务器。Nginx是由Igor Sysoev为俄罗斯访问量第二的Rambler.ru站点开发的,第一个公开版本0.1.0发布于2004年10月4日。其将源代码以类BSD许可证的形式发布,因它的稳定性、丰富的功能集、示例配置文件和低系统资源的消耗而闻名。2011年6月1日,nginx 1.0.4发布。
Nginx是一款轻量级Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行。由俄罗斯的程序设计师Igor Sysoev所开发,供俄国大型的入口网站及搜索引擎Rambler(俄文:Рамблер)使用。其特点是占有内存少,并发能力强,事实上nginx的并发能力确实在同类型的网页服务器中表现较好,中国大陆使用nginx网站用户有:百度、京东新浪网易腾讯淘宝等。
 
 
贴出完整的配置文件

#运行用户
#user nobody;
#此参数修改为与CPU个数一致
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

pid logs/nginx.pid;

#后添的
worker_rlimit_nofile 51200;

events {
#单个后台worker process进程的最大并发链接数
worker_connections 51200;
}
#设定http服务器,利用它的反向代理功能提供负载均衡支持
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 logs/access.log main;

server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;

#充许客户端请求的最大单个文件字节数
client_max_body_size 10m;

client_body_buffer_size 128k;

#跟后端服务器连接的超时时间 s
proxy_connect_timeout 5;

#连接成功后等候后端服务器响应时间
proxy_read_timeout 60;

#后端服务器数据回传时间
proxy_send_timeout 30;

#代理请求缓存区
proxy_buffer_size 8k;

#同上,保存用几个buffer每个最大空间是多少
proxy_buffers 4 32k;

#如果系统很忙时可以申请更大的proxy_buffers,官方推荐*2
proxy_busy_buffers_size 64k;

#缓存临时文件的大小
proxy_temp_file_write_size 128k;

#sendfile 指令指定 nginx 是否调用 sendfile 函数(zero copy 方式)来输出文件,对于普通应用,
#必须设为 on,如果用来进行下载等应用磁盘IO重负载应用,可设置为 off,以平衡磁盘与网络I/O处理速度,降低系统的uptime.
sendfile on;
#tcp_nopush on;

#连接超时时间
#keepalive_timeout 0;
keepalive_timeout 60;

tcp_nodelay on;
#开启gzip压缩
#gzip on;
# gzip_disable "MSIE [1-6]\.(?!.*SV1)";

#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;

upstream test_nginx {
#ip_hash;
least_conn; #最少连接
server 127.0.0.1:8080 max_fails=2 fail_timeout=30s;
server 192.168.137.128:8080 max_fails=2 fail_timeout=30s ;
}

server {
listen 9999;#监听的端口号 一般是80端口
server_name test_nginx;

proxy_redirect off;

access_log logs/tset_nginx.log combined;
#charset koi8-r;
#access_log logs/host.access.log main;

location / {
root /root;#定义服务器的默认网站根目录位置
index index.html index.htm;
proxy_pass http://test_nginx;
proxy_set_header Host $host;
proxy_set_header X-Real-Ip $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

location /status{
stub_status on;
access_log off;
auth_basic "NginxStatus";
auth_basic_user_file htpasswd;
}

location ~ \.jsp$ {
proxy_pass http://test_nginx;
}

location ~ \.(html|js|css|png|gif)$ {
#root html;
proxy_pass http://test_nginx;

# root /var/www/virtual/htdocs;
#过期30天,静态文件不怎么更新,过期可以设大一点,如果频繁更新,则可以设置得小一点。
expires 30d;
}

#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 404 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 ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
# ssl_prefer_server_ciphers on;

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

}

常用命令 1 开启nginx: start nginx    2 重新加载配置文件:nginx -s reload 3 关闭nginx  : nginx -s stop 
 
 
 
 

初识nginx+tomcat的更多相关文章

  1. 初识Nginx及编译安装Nginx

    初识Nginx及编译安装Nginx 环境说明: 系统版本    CentOS 6.9 x86_64 软件版本    nginx-1.12.2 1.什么是Nginx? 如果你听说或使用过Apache软件 ...

  2. Nginx + Tomcat Windows下的负载均衡配置

     Nginx + Tomcat Windows下的负载均衡配置 一.为什么需要对Tomcat服务器做负载均衡?    Tomcat服务器作为一个Web服务器,其并发数在300-500之间,如果超过50 ...

  3. HappyAA服务器部署笔记1(nginx+tomcat的安装与配置)

    这是本人的服务器部署笔记.文章名称叫"部署笔记1"的原因是之后我对这个进行了改进之后,会有"部署笔记2","部署笔记3"...循序渐进,估计 ...

  4. nginx + tomcat配置负载均衡

    目标:Nginx做为HttpServer,连接多个tomcat应用实例,进行负载均衡. 注:本例程以一台机器为例子,即同一台机器上装一个nginx和2个Tomcat且安装了JDK1.7. 1.安装Ng ...

  5. Nginx+Tomcat+Redis实现负载均衡、资源分离、session共享

    Nginx+Tomcat+Redis实现负载均衡.资源分离.session共享 CentOS安装Nginx http://centoscn.com/CentosServer/www/2013/0910 ...

  6. nginx+tomcat+二级域名静态文件分离支持mp4视频播放配置实例

    nginx+tomcat+二级域名静态文件分离支持mp4视频播放配置实例 二级域名配置 在/etc/nginx/conf.d/目录下配置二级域名同名的conf文件,路径改成对应的即可 statics. ...

  7. Nginx+Tomcat构建动、静分离WEB架构

    一.简介 二.环境介绍 三.后端服务器安装配置 四.安装论坛 五.安装配置前端Nginx服务器 六.验证服务 一.Tomcat简介 Tomcat是Apache 软件基金会(Apache Softwar ...

  8. nginx+tomcat+dubbo单机部署多台dubbo应用

    前面的博客已经介绍如何使用nginx+tomcat,今天做的是如何在单台服务器上如何部署多台dubbo 应用的集群. 由于在项目中遇到了这个问题,今天就把它记录下来. 1.

  9. 通过Nginx+tomcat+redis实现反向代理 、负载均衡及session同步

    一直对于负载均衡比较陌生,今天尝试着去了解了一下,并做了一个小的实验,对于这个概念有一些认识,在此做一个简单的总结 什么是负载均衡 负载均衡,英文 名称为Load Balance,指由多台服务器以对称 ...

随机推荐

  1. 安装完Oracle数据库,给scott账户解锁方法

    装完了Oracle 10g数据库,忘了给scott账户解锁.这时可以在sql plus工具里(开始|所有程序|<Oracle-Home>|应用程序开发|SQL Plus),也可以在控制台通 ...

  2. codeforces 342D Xenia and Dominoes(状压dp+容斥)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud D. Xenia and Dominoes Xenia likes puzzles ...

  3. 轻量jquery框架之--组件交互基础设计

    概要 组件交互基础,即考虑在JQUERY对象下($)下扩展所有组件都需要用到的通用api,如ajax入口.对表单的操作.html片段加载.通用的配合datagrid通用的curd客户端对象等. 扩展a ...

  4. CSS布局部分知识总结

    一 切图 通过一个周的切图练习,我发现只有亲自动手后才能通过问题不断加深技术,要熟练掌握HTML页面编写时候时PHOTOSHOP操作. 以下一些知识点在网络布局时也是很重要的. 1.ul标签在谷歌.火 ...

  5. Js函数加括号、不加括号(转)

    函数只要是要调用它进行执行的,都必须加括号.此时,函数()实际上等于函数的返回值.当然,有些没有返回值,但已经执行了函数体内的行为,这个是根本,就是说,只要加括号的,就代表将会执行函数体代码. 不加括 ...

  6. 利用树莓派跑python爬虫的简单教程——从无到有

    因为学校项目的原因入手了树莓派,到手先折腾了两天,发现网上的教程大都是拿他搭建服务器,mail,或者媒体服务器之类,对于在学校限时的宽带来说有点不太现实,不过低功耗适合一直开着的确启发了我.所以想到拿 ...

  7. 设置PlaceHolder的颜色

    input::-webkit-input-placeholder{ color:green; } input::-webkit-input-placeholder { color: #999; } i ...

  8. 在 .pro里加入 QMAKE_CXXFLAGS += /MP 将并行编译,加快编译速度(姚冬的办法)

    但是只对VC编译器有效果. 另外还可以自己设置stdafx.h文件 http://www.zhihu.com/question/23045749

  9. PCRE-正则库及用法

    摘自http://blog.chinaunix.net/uid-26575352-id-3517146.html    在C语言中利用PCRE实现正则表达式 http://www.pcre.org/ ...

  10. Mac 下纯lua(三)

    文件处理 直接使用io调用 io.close();文件流关闭 io.flush():如果文件流以bufferd缓存模式处理,输入不会立即存入文件,需要调用本函数 io.input(file):输入 i ...