#user nobody;
worker_processes 2;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
error_log /usr/local/nginx/logs/nginx_error.log crit;
pid /usr/local/nginx/nginx.pid;
events {
worker_connections 65535;
use epoll;
}
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;
#General Options
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_body_buffer_size 8m; #256k
server_tokens off;
ignore_invalid_headers on;
recursive_error_pages on;
server_name_in_redirect off;
sendfile on;
#timeouts
keepalive_timeout 60;
#client_body_timeout 3m;
#client_header_timeout 3m;
#send_timeout 3m;
#TCP Options
tcp_nopush on;
tcp_nodelay on;
#size limits
client_max_body_size 50m;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
upstream servers {
server 192.168.1.108:8080;
#server x.x.x.x:8080 max_fails=0 weight=1; #8080为tomcat端口
}
server {
listen 80;
server_name test.zl.com;
#charset koi8-r;
charset utf-8;
access_log logs/access.log main;
location / {
index index.html index.htm;
root /prod/nginxtest; #设定访问路径
}
location ~* \.(htm|html|gif|jpg|jpeg|png|bmp|ico|rar|css|js|zip|java|jar|txt|flv|swf|txt|wma)$
{
root /prod/nginxtest;
expires 24h;
}
location ~*\.(jsp|do|action)$
{
index index.jsp;
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /status {
stub_status on;
access_log on;
allow all;
}
#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;
# }
#}
}
分享到:
相关推荐
尽管还是测试版,但是,Nginx 已经因为它的稳定性、丰富的功能集、示例配置文件和低系统资源的消耗而闻名了。 使用 Nginx 前必须了解的事项 目前官方 Nginx 并不支持 Windows,您只能在包括 Linux、UNIX、BSD ...
nginx+tomcat多域名配置 尝试过多次是比较ok!写的比较的简单有需要的朋友可以自己搭建试试做了session共享
nginx+tomcat负载均衡简单配置
NULL 博文链接:https://liangjian103.iteye.com/blog/1617213
小型网站上进行的nginx+tomcat负载均衡与动静分离
Nginx+tomcat配置集群负载均衡,了解了二者之间的区别于应用场景,对于搭建服务帮助很大。nginx配置简单,不想apache配置那么复杂
2. 利用nginx的基于访问ip的hash路由策略,保证访问的ip始终被路由到同一个tomcat上,这个配置更简单。但是我们的应用很可能是某一个局域网大量用户同时登录,这样负载均衡就没什么作用了。 3. 利用memcached把多个...
nginx+tomcat 负载、集群简单搭建,适合新手。
nginx+Tomcat集群简单配置及相关文档
配置简单易懂,只需对nginx和tomcat集群稍作配置即可实现
目前可以和Tomcat做负载均衡的主流服务器是Apache,但是Nginx由于功能多、配置简单等优点逐渐成为很多负载均衡服务器的首选。Nginx的并发数可达到50000,所以理论上可以和Tomcat以1:100的比例来配置,这样便可以很好...
Linux下安装nginx和安装多个tomcat的方法这里不过多介绍,不清楚的可参考: Linux安装nginx: ... Linux安装多个tomcat: ...当我们服务器安装好了nginx,...安装了4个tomcat,并且配置好了各端口号,分别对应8080,8081,8082
简单通过nginx+tomcat搭建负载均衡,rar包内提供nginx工具及搭建配置说明文档word
博主最近在优化一个javaweb项目,该项目之前一直都是...windows下安装Nginx非常简单,去官网下载压缩包解压后并且双击解压目录下的nginx.exe程序即可。然后在浏览器输入localhost可出现下图,即表示nginx已经在工作。
作者:RKun595,来自原文地址 由于最近在学习微信小程序开发,所以在阿里云申请了一个免费的https证书,这个证书申请...然后修改nginx配置文件 sudo vi /etc/nginx/nginx.conf 加上一个监听服务 upstream tomcat
windows下测试 nginx+tomcat实现java web项目的动静分离 1. 安装nginx,访问静态资源 ...修改配置文件nginx.conf,添加如下配置: #正则匹配以static开头的请求,比如/test1/static/js… locatio
这主要是因tomcat处理静态资源的速度比较慢,所以首先想到的就是把所有静态资源(JS,CSS,image,swf),提到单独的服务器,用更加快速的HTTP服务器,这里选择了nginx了,nginx相比apache,更加轻量级,配置更加简单,...
基本架构是硬负载(ReadWhere)+ 软负载(Nginx)+ Tomcat集群,现在的问题是SSl证书要配置在哪里,直接配置在硬负载上?还是分别配置在Nginx和Tomcat上?还是其他的配置方法呢? 首先在硬负载上配置放弃了,然后...