- 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.
推薦閱讀
- 每天5分鐘玩轉(zhuǎn)Kubernetes
- 無蘋果不生活 OS X Mountain Lion隨身寶典
- SOA實(shí)踐者說
- 構(gòu)建可擴(kuò)展分布式系統(tǒng):方法與實(shí)踐
- 精解Windows8
- Installing and Configuring Windows 10:70-698 Exam Guide
- Linux網(wǎng)絡(luò)內(nèi)核分析與開發(fā)
- Windows Server 2012網(wǎng)絡(luò)操作系統(tǒng)企業(yè)應(yīng)用案例詳解
- Windows 7中文版從入門到精通(修訂版)
- AutoCAD 2014中文版從入門到精通
- 一學(xué)就會(huì):Windows Vista應(yīng)用完全自學(xué)手冊(cè)
- iOS 8開發(fā)指南
- 完美應(yīng)用Ubuntu(第2版)
- 基于Arduino的嵌入式系統(tǒng)入門與實(shí)踐
- Mastering Eclipse Plug-in Development