使https生效的唯一方法是
server.xml在
<service>标记下的文件上写入适当的连接器。设置连接器后,您可以使用http或https访问服务器中的所有应用程序。唯一的区别是使用了哪种连接器。通常,http和https的连接器如下所示:
<Connector port="80" protocol="HTTP/1.1"maxThreads="150" connectionTimeout="20000"redirectPort="443"URIEncoding="UTF-8" compression="on"/><Connector port="443" protocol="HTTP/1.1"maxThreads="150" connectionTimeout="20000"SSLEnabled="true" scheme="https" secure="true"keystoreFile="conf/.keystore"keystorePass="changeit"clientAuth="false" sslProtocol="TLS"URIEncoding="UTF-8" compression="on"/>
然后,您可以通过添加
transport-guarantee标记来强制您的应用程序始终使用https,而该标记
web.xml最终会是这样的:
<security-constraint> <web-resource-collection> <web-resource-name>Administrators</web-resource-name> <url-pattern>/*</url-pattern> </web-resource-collection> <auth-constraint> <role-name>Administrators</role-name> </auth-constraint> <user-data-constraint> <transport-guarantee>CONFIDENTIAL</transport-guarantee> </user-data-constraint></security-constraint>
您可以
transport-guarantee为定义的不同Web资源更改。因此,您可以保护站点的某些部分,而不能保护其他部分。
最后,插入连接器
server.xml并不会强制您在所有应用程序中使用https。它仅允许使用https连接器。



