Resin配置SSL说明

resin 配置:

 <web-app  id='examples/tags'>
    
<directory-servlet id='false'/>     //<directory-servlet id='false'/>配置使得resin禁止目录浏览
  </web-app>

  

在window里配置resin虚拟主机

Resin服务器配置SSL的访问功能,有几种方法

[1]

1.       Unix下使用OpenSSL。(http://www.openssl.org/

2.       使用SUNJSSE。(http://java.sun.com/products/jsse

3. ...

我们这里介绍第二种方法,在Windows 2000下的实现。

 

准备工作

1.       Windows 2000 Server

2.       J2SDK 1.4.x。(已经包括了JSSE

3.       Resin 2.1.x

4.       JSSEkeytool用法[2]

 

步骤

1.       创建一个服务器证书

a)         下面讲如何使用Sunkeytool来生成一个服务器证书。看下图:

一般来说,keystore密码和mykey主密码应该设置成一样的。

这时,证书文件已经保存在本例中的C:/resin-2.1.11/keys/server.keystore

2.       配置Resinresin.conf

ResinSSL配置需要对<http-server>进行扩展,增加几个新的元素。下表中红色文字为新增部分。其中,key-store-file为上一步中生成的证书文件存放地址(相对resin根目录),key-store-password为上一步中为证书设置的密码。

<caucho.com>

   

<security-provider id='com.sun.net.ssl.internal.ssl.Provider'/>

 

 

 

 

 

 

<!-- declare a new HTTP server on port 443 (standard port for HTTPS),

 

 

 

 

 

 

      - with SSL enabled -->

 

 

 

 

 

 

 

<http-server>

  <app-dir>doc</app-dir>

 

  <!-- the http port -->

  <http port=80/>

 

  <!-- the srun port, read by both JVM and plugin -->

  <srun host='localhost' port='6802'/>

 

  <http port=443>

 

 

 

 

 

 

    <ssl>true</ssl>

 

 

 

 

 

 

     <key-store-file>keys/server.keystore</key-store-file>

 

 

 

 

 

 

     <key-store-password>YourPasswordHere</key-store-password>

 

 

 

 

 

 

  </http>

 

 

测试

使用上面的配置,启动resin服务,我们可以访问https://localhost

一个最快的测试方式是新建一个内容如下的JSP文件并访问他:

Secure? <%= request.isSecure() %>

 

 

运行/bin/httpd.exe,结果如下:


 

访问https://localhost/,跳出一个安全警报,选择是。


 

(如果不想跳出这个安全警报,有几点要做:1 将证书安装到客户端的IE中;2 证书生成时的CN(即名字与姓氏)必须使用服务器的机器名,即DNS名。)

 

浏览器浏览https://localhost/,效果如下:


 

浏览https://localhost/isSecure.jsp测试文件

 

这表示我们配置Resin使用SSL成功。



在window里配置resin虚拟主机

< host  id ="test.domain.com"   >  
   
< web-app  id ='/'  >  
   
< app-dir > D:/resin/webapps/test </ app-dir >     //指定web程序的路径 
      
< classpath  id ='WEB-INF/classes' 
                 
source ='WEB-INF/classes' 
                 
compile ='true'/> 

      
<session-config >  
        
< session-max > 4096 </ session-max >  
        
< session-timeout > 30 </ session-timeout >  
        
< enable-cookies > true </ enable-cookies >  
        
< enable-url-rewriting > true </ enable-url-rewriting >  
      
</ session-config >  

      
< multipart-form  upload-max ='-1'/> 
      
<servlet-mapping url-pattern ='*.jsp'  servlet-name ='jsp'/> 
      
<servlet-mapping url-pattern ='/servlet/*'  servlet-name ='invoker'/> 
    
</web-app >  
    
</ host >  



访问test.domain.com/*.jsp  就可以访问D:/resin/webapps/test这个目录的jsp了。



resin配置服务端口:

< http-server >
    
< app-dir > doc </ app-dir >

   
< http  port ='8080'/> 
//访问方式:localhost:8080
//如果改为 <http port
='80'/>   访问为localhost
 

</http-server
>

 



resin log日志配置:

在host中加入:

  < error-log  id ='log/error.log'/>
 
<stdout-log   id ='log/stdout.log'/>   


就可以在log文件夹中看到error.log  和stdout.log了。
但是必须首先配置在server下

< log  id ='/log'  href ='stdout:'  timestamp ='[%Y-%m-%d  %H:%M:%S.%s]' />

 

如果在配置另外一个虚拟主机,同样配置了Log,则有一样的效果(stdouttest.log)

< host  id ="test.domain.com"   >  

   
< stdout-log    id ='log/stdouttest.log'/> 
  

</host
>


配置之后,控制台不再显示日志信息,而是把日志信息显示到log文件中。



resin配置应用:

 

  < web-app  id ='xfaq'  app-dir ="D:/workspace/xfaq/epro" />


一般我们只需将应用工程copy到resin的webapps下就可以了,但是如果我们不想挪动我们的工程文件夹,就需要在配置文件中写上面的代码了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值