我有一个 Java 应用程序,我最近将它迁移到了 Amazon AWS、带有 tomcat7 的 Beanstalk 和一个 MySQL 数据库 (RDS)。
我想合并基本的 Tomcat 身份验证,并在 WEB_INF 下创建了以下文件:
网页.xml
<security-constraint>
<display-name>UserConstraint</display-name>
<web-resource-collection>
<web-resource-name>UserConstraint</web-resource-name>
<description/>
<url-pattern>/text.txt</url-pattern>
</web-resource-collection>
<auth-constraint>
<description/>
<role-name>authz-user</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>file</realm-name>
</login-config>
<security-role>
<description>Application user role</description>
<role-name>authz-user</role-name>
</security-role>
用户文件
<?xml version="1.0" encoding="UTF-8"?>
<tomcat-users>
<role rolename="authz-user"/>
<user username="name" password="pass" roles="authz-user"/>
</tomcat-users>
WEB-INF/.ebextensions/context.xml
<?xml version='1.0' encoding='utf-8'?>
<Context antiJARLocking="true" path="/APPNAME>
<WatchedResource>WEB-INF/users.xml</WatchedResource>
</Context>
我收到登录请求,但不接受用户/密码。我从不同的来源到达这里,所以我不确定在这种环境下是否应该这样做。我怎样才能让用户被接受?是否有另一种创建用户的方法?
发现几个错误:
.ebextensions 文件夹必须位于 Web 应用程序的根目录中。
此文件夹中的 server-update.config 文件必须包含:
container_commands:
replace-config:
command: "cp .ebextensions/tomcat-users.xml /usr/share/tomcat7/conf/tomcat-users.xml"
users.xml 重命名为 tomcat-users.xml。
现在它起作用了。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句