Nginx Tomcat 动静分离提高系统性能

栏目: 服务器 · 发布时间: 8年前

内容简介:Nginx Tomcat 动静分离提高系统性能

(一)概念

1、动静分离:将 Web 应用程序中静态和动态的内容分别放在不同的 Web 服务器上,有针对性的处理动态和静态内容,从而达到性能的提升。

2、静态文件如:css、html、jpg、js等文件,动态文件:.jsp、.do、.asp等等。

(二)动静分离实现

1、配置nginx.cnf配置文件如下:

server {     listen 80;     server_name 127.0.0.1; # www.aaa.com域名 或 ip 192.168.1.115(本机ip)     location / {         proxy_pass http://localhost:8088; # 对应端口号8080     }   #静态资源     location ~ .*\.(js|css|htm|html|gif|jpg|jpeg|png|bmp|swf|ioc|rar|zip|txt|flv|mid|doc|ppt|pdf|xls|mp3|wma)$ {        root static;#静态资源位置  location ~ \.(jsp|jspx|do|action)(\/.*)?$ {             proxy_set_header real_ip $remote_addr;              proxy_pass http://127.0.0.1:8088;         } }

2、存放文件:将静态资源放在nginx安装目录下的static文件夹中,static文件夹下可以放 很有静态资源的images、css、js 等文件夹。

3、tomcat中显示静态资源: 在jsp中直接指向根目录下资源即可,如下:

<link rel="stylesheet" href="/css/jquery-weui.css">  ![](/images/account.png)  <script src="/js/tj.js"></script>

4、访问:

Nginx中直接显示静态资源:http://127.0.0.1/images/account.png

Tomcat中显示静态资源:http://127.0.0.1/index

总结:Nginx Tomcat 动静分离其实很简单,主要是配置静态资源,将Tomcat中的静态资源移除,从而弥补Tomcat对静态资源的弱处理能力,提高系统性能,提高并发处理能力。


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Compilers

Compilers

Alfred V. Aho、Monica S. Lam、Ravi Sethi、Jeffrey D. Ullman / Addison Wesley / 2006-9-10 / USD 186.80

This book provides the foundation for understanding the theory and pracitce of compilers. Revised and updated, it reflects the current state of compilation. Every chapter has been completely revised ......一起来看看 《Compilers》 这本书的介绍吧!

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具