nginx+tomcat实现动静分离架构

最近又要准备新的项目架构,涉及到apache-tomcatcluster的相关问题,主要是以nginx+tomcat,博文为生成环境简化,香港空间,重在架构思想。

准备安装环境,安装pcre,可以使用pcre源码或者rpm包安装

yum install -y pcre*

安装nginx

nginx.conf配置

user nobody nobody;worker_processes 2;error_log /usr/local/nginx/logs/error.log crit;pid/usr/local/nginx/nginx.pid;worker_rlimit_nofile 65535;events{use epoll;worker_connections 65535;}http{includemime.types;default_type application/octet-stream;#charset gb2312;server_names_hash_bucket_size 128;client_header_buffer_size 32k;large_client_header_buffers 4 32k;client_max_body_size 8m;sendfile on;tcp_nopushon;keepalive_timeout 60;tcp_nodelay on;fastcgi_connect_timeout 300;fastcgi_send_timeout 300;fastcgi_read_timeout 300;fastcgi_buffer_size 64k;fastcgi_buffers 4 64k;fastcgi_busy_buffers_size 128k;fastcgi_temp_file_write_size 128k;gzip on;gzip_min_length 1k;gzip_buffers4 16k;gzip_http_version 1.0;gzip_comp_level 2;gzip_typestext/plain application/x-javascript text/css application/xml;gzip_vary on;#limit_zone crawler $binary_remote_addr 10m;log_format access ‘$remote_addr – $remote_user [$time_local] “$request” ”$status $body_bytes_sent “$http_referer” ””$http_user_agent” $http_x_forwarded_for’;access_log /usr/local/nginx/logs/access.log access;server{listen 80;server_name web1.example.com;index index.html index.htm index.php;root /usr/local/nginx/html;#limit_conn crawler 20;location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)${root/usr/local/nginx/html;expires30d;}location ~ (\.jsp)|(\.do)${proxy_pass :8080;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;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;}location ~ .*\.(js|css)?${expires1h;}}}

2、安装、配置tomcat

先安装jdk

然后在source/root/.bash_profile

安装tomcat

在<host></host>标签之间添加上:

在<welcome-file-list>与<welcome-file>index.html</welcome-file>之间添加上:

html

在/usr/local/tomcat/webapps/html目录下新建一个index.jsp,一个index.do

然后在浏览器上访问静态页面index.html

在浏览器上访问动态页面index.jsp、index.do

本文出自 “老徐的私房菜” 博客,谢绝转载!

,美国空间,香港服务器租用离开睁眼闭眼看见的城市,逃离身边的纷纷扰扰,

nginx+tomcat实现动静分离架构

相关文章:

你感兴趣的文章:

标签云: