nginx是俄罗斯出品的注明的反向代理服务器,是apache的替代品之一。目前包括sina,腾讯在内的多家互联网公司都在用这个产品。
最近nginx发布了windows下的程序。
nginx的官网下载稳定版本。
之后修改配置文件conf/nginx.conf
找到server哪一行,配置如下
server {
listen 8099;
server_name localhost;
location / {
root html;
index index.html index.htm index.php index.jsp;
proxy_pass http://127.0.0.1:8080;
}
由于我的机器上80端口跑的apache,所以我就用8099来拍nginx,并将请求都发给了8080端口上的resin。如果你只需要将jsp请求发过去,那么你还要在location哪一行上用正则表达式写下你的匹配模式。
总而言之,配置真的好简单。
之后启动resin,再启动nginx就ok了
web项目中url rewright的功能是一个很常见得功能,实现的方式多种多http://ohacker.com/wp-admin/post-new.php样,最常见的莫过于在web服务器中设置,例如在Apache中设置。而如果你使用Java开发,那么还有个更多的方案供你选择如使用url rewrite filter ,而如果你是使用resin(版本需要>3.1)作为你的application server,那么你还可以使用resin自带的url 重写功能。
首先,你必须使用resin-web.xml代替常规的web.xml作为你的项目部署描述文件,其次,你需要在描述文件中指定一个url重写的配置文件。再在这个文件中配置。
resin-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://caucho.com/ns/resin"
xmlns:resin="http://caucho.com/ns/resin/core">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<rewrite-dispatch>
<import path='WEB-INF/rewrite.xml'/>
</rewrite-dispatch>
</web-app>
rewrite.xml
<rewrite-dispatch xmlns="http://caucho.com/ns/resin"
xmlns:resin="http://caucho.com/ns/resin/core">
<redirect regexp="^/tst" target="https://ohacker.com/tst">
<when secure="false" />
</redirect>
</rewrite-dispatch>