---
title: "对tomcat/jboss发布的某个项目要求https方式访问"
author: "wewi"
date: "2008-07-10T20:11:00Z"
tags: []
slug: "tomcat-jboss-https"
draft: false
lastmod: "2008-07-10T20:11:00Z"
id: 466126
url: "https://wewi.iteye.com/blog/466126"
---

原来jboss上面只有1个项目，在server.xml设定了要用https方式才能访问。现在又增加了一个新项目，新项目普通用户都能访问，为此，修改了server.xml，设定同时开放80和443端口，但是这样所有的项目都可以用http方式打开了，怎么才能保持原来的项目仍然用https才能访问呢。

查了很多资料，最后发现修改项目的WEB-INF/web.xml可以实现对某个项目访问权限的控制。如果要保证只能用https方式才能打开项目，要在web.xml增加以下内容

```
 <security-constraint>  

     <web-resource-collection >  

         <web-resource-name >SSL</web-resource-name>  

         <url-pattern>/*</url-pattern>  

     </web-resource-collection>  

     <user-data-constraint>  

         <transport-guarantee>CONFIDENTIAL</transport-guarantee>  

     </user-data-constraint>  

  </security-constraint>    
```