- Learning Continuous Integration with Jenkins(Second Edition)
- Nikhil Pathania
- 226字
- 2021-07-02 21:18:35
Configuring the Apache Tomcat server
In this section, we will enable access to the Tomcat Manager app and Host Manager:
- Open the tomcat-users.xml file for editing, which is present inside the /opt/tomcat/conf directory:
sudo nano /opt/tomcat/conf/tomcat-users.xml
- The file will look something like the following, for simplicity, I have ignored the comments inside the file:
<?xml version="1.0" encoding="UTF-8"?> . . . <tomcat-users xmlns="http://tomcat.apache.org/xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd" version="1.0"> . . . <!-- <role rolename="tomcat"/> <role rolename="role1"/> <user username="tomcat" password="<must-be-changed>"
roles="tomcat"/> <user username="both" password="<must-be-changed>"
roles="tomcat,role1"/> <user username="role1" password="<must-be-changed>"
roles="role1"/> --> </tomcat-users>
- From the previous file, you can see the role and user fields are commented. We need to enable a role and a user to allow access to the Tomcat Manager app page:
<role rolename="manager-gui"/> <role rolename="admin-gui"/> <user username="admin" password="password"
roles="manager-gui,admin-gui"/>
- Finally, the file should look something as shown here (comments removed):
<?xml version="1.0" encoding="UTF-8"?> <tomcat-users xmlns="http://tomcat.apache.org/xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd" version="1.0"> <role rolename="manager-gui"/> <role rolename="admin-gui"/> <user username="admin" password="password"
roles="manager-gui,admin-gui"/> </tomcat-users>
- Type Ctrl + X and choose Y to save and close the file.
- By default, you are allowed to access Manager and Host Manager applications only from within the Apache Tomcat server. Since, we will be managing services running on Apache from a remote machine, we would need to remove these restrictions.
- Open the following two files, /opt/tomcat/webapps/manager/META-INF/context.xml and /opt/tomcat/webapps/host-manager/META-INF/context.xml.
- Inside these files, comment the following section:
<Context antiResourceLocking="false" privileged="true" > <!--<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />--> <Manager sessionAttributeValueClassNameFilter="java\.lang\
.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\
.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\
.(?:Linked)$ </Context>
- Type Ctrl + X and choose Y to save and close the file.
- Restart the Tomcat server using the following command:
sudo systemctl restart tomcat
- Try to access the Manager app and the Host Manager from the Apache Tomcat server home page.
推薦閱讀
- pcDuino開發實戰
- BPEL and Java Cookbook
- Persistence in PHP with the Doctrine ORM
- Extending Bootstrap
- Instant Optimizing Embedded Systems using Busybox
- Ceph分布式存儲實戰
- Linux系統最佳實踐工具:命令行技術
- Hands-On GPU Programming with Python and CUDA
- Windows Vista終極技巧金典
- Linux網絡操作系統項目教程(RHEL 7.4/CentOS 7.4)(第3版)(微課版)
- Java EE 8 High Performance
- Linux系統管理初學者指南:基于CentOS 7.6
- OpenSolaris紅寶書
- SAP后勤模塊實施攻略:SAP在生產、采購、銷售、物流中的應用
- 分布式實時處理系統:原理、架構與實現