Tomcat의 루트에 내 응용 프로그램 배포
내 응용 프로그램의 war 파일이 있습니다. 루트 수준에서 배포해야합니다. 현재 URL은 http://localhost:8080/war_name/application_name
입니다.
몇 가지 옵션이 있습니다.
ROOT/
Tomcat에서 기본 제공 디렉토리를 제거하고ROOT.war
배포 하기 전에 war 파일의 이름을 바꿉니다 .(예제에서
war_name.war
와 같이) 전쟁을 전개 하고 war 파일을 사용 하도록 컨텍스트 루트 를 구성conf/server.xml
하십시오.<Context path="" docBase="war_name" debug="0" reloadable="true"></Context>
첫 번째는 더 쉽지만 조금 더 복잡합니다. 두 번째 방법은 아마도 더 우아한 방법 일 것입니다.
Tomcat v.7 (바닐라 설치)
conf / server.xml에서 </Host>
닫는 태그 바로 앞에 파일 끝쪽에 다음 비트를 추가하십시오 .
<Context path="" docBase="app_name">
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
</Context>
참고 는 Docbase 속성. 중요한 비트입니다. 루트 웹앱을 변경하기 전에 app_name을 배포했는지 확인하거나 압축을 푼 웹앱 (app_name)을 Tomcat의 webapps 폴더에 복사하면됩니다. 시작, 루트 방문, app_name 참조!
이러한 변경 사항이있는 Tomcat 7의 경우 /에서 myAPP에 액세스하고 / ROOT에서 ROOT에 액세스 할 수 있습니다
<Context path="" docBase="myAPP">
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
</Context>
<Context path="ROOT" docBase="ROOT">
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
</Context>
<Host>
server.xml 의 섹션에 위의 추가
나는 내 대답이 다른 대답과 겹친다는 것을 알고 있지만 이것은 몇 가지 장점이있는 완벽한 솔루션입니다. 이것은 Tomcat 8에서 작동합니다.
- 기본 응용 프로그램은 루트에서 제공됩니다
- 웹 인터페이스를 통한 war 파일 배포가 유지됩니다.
- 주 응용 프로그램은 포트 80에서 실행되며 관리자 만 관리 폴더에 액세스 할 수 있습니다 (* nix 시스템에는 80에 바인딩하기 위해 수퍼 유저가 필요하지만 Windows에서는 문제가되지 않습니다).
즉, Tomcat을 한 번만 다시 시작하면 업데이트 된 war 파일을 문제없이 배포 할 수 있습니다.
1 단계 : server.xml 파일에서 커넥터 항목을 찾아서 다음 항목으로 바꾸십시오.
<Connector
port="8080"
protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector
port="80"
protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
2 단계 : <Host ...>
태그 내에 컨텍스트를 정의하십시오 .
<Context path="/" docBase="CAS">
<WatchedResource>WEB-INF/web.xml</WatchedResource>
</Context>
<Context path="/ROOT" docBase="ROOT">
<WatchedResource>WEB-INF/web.xml</WatchedResource>
</Context>
<Context path="/manager" docBase="manager" privileged="true">
<WatchedResource>WEB-INF/web.xml</WatchedResource>
</Context>
<Context path="/host-manager" docBase="host-manager" privileged="true">
<WatchedResource>WEB-INF/web.xml</WatchedResource>
</Context>
webapp 폴더의 모든 앱을 다루었습니다. 첫 번째는 루트와 기본 앱을 효과적으로 전환합니다. ROOT가 켜져 http://example.com/ROOT
있고 기본 응용 프로그램이 켜져 http://example.com/
있습니다. 비밀번호로 보호 된 웹앱에는 privileged="true"
속성이 필요 합니다.
When you deploy a CAS.war file that matches with the root (<Context path="/" docBase="CAS">
you have to reload that one in the admin panel as it does not refresh with the deployment.
Do not include the <Context path="/CAS" docBase="CAS">
in your contexts as it disables the manager option to deploy war files. This means that you can access the app in two ways: http://example.com/
and http://example.com/APP/
Step 3: In order to prevent unwanted access to the root and manager folder, add a valve
to those context tags like this:
<Context path="/manager" docBase="manager" privileged="true">
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
addConnectorPort="true"
allow="143\.21\.2\.\d+;8080|127\.0\.0\.1;8080|::1;8080|0:0:0:0:0:0:0:1;8080"/>
</Context>
This essentially limits access to the admin web app folder to people from my own domain (fake IP address) and localhost when they use the default port 8080 and maintains the ability to dynamically deploy the war files through the web interface.
If you want to use this for multiple apps that are using different IP addresses, you can add the IP address to the connector (address="143.21.2.1"
).
If you want to run multiple web apps from the root, you can duplicate the Service tag (use a different name for the second) and change the docbase of the <Context path="/" docBase="CAS">
to for example <Context path="/" docBase="ICR">
.
Remove $CATALINA_HOME/webapps/ROOT
. Update $CATALINA_HOME/conf/server.xml
, make sure that Host element look like the following text:
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="false" deployOnStartup="false">
<Context path="" docBase="myApp"></Context>
It works with Tomcat 8. autoDeploy and deployOnStartup need to set to false to prevent tomcat from deploying myApp
twice.
The fastest way.
Make sure you don't have ROOT app deployed, undeploy if you have one
Rename your war to ROOT.war, deploy, thats all, no configuration changes needed
Adding on to @Rob Hruska's sol, this setting in server.xml inside section works:
<Context path="" docBase="gateway" reloadable="true" override="true"> </Context>
Note: override="true" might be required in some cases.
open tomact manager url :- http://localhost:8080/manager/html/
then in applications you see a application having path as "/" is deployed
simply Undeploy this.
Rename your application's war file as ROOT.war and just place at path :-
C:\Program Files\Apache Software Foundation\Tomcat 8.5\webapps
start your Tomcat No extra configuration needed.
Now we can see our application home page or configured url at http://localhost:8080
In my server I am using this and root autodeploy works just fine:
<Host name="mysite" autoDeploy="true" appBase="webapps" unpackWARs="true" deployOnStartup="true">
<Alias>www.mysite.com</Alias>
<Valve className="org.apache.catalina.valves.RemoteIpValve" protocolHeader="X-Forwarded-Proto"/>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="mysite_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b"/>
<Context path="/mysite" docBase="mysite" reloadable="true"/>
</Host>
참고URL : https://stackoverflow.com/questions/5328518/deploying-my-application-at-the-root-in-tomcat
'IT story' 카테고리의 다른 글
입력에서 ng-model의 필터 (0) | 2020.07.10 |
---|---|
WPF에서 모달 대화 상자를 만드는 방법은 무엇입니까? (0) | 2020.07.10 |
node.js에서 파일을 어떻게 이동합니까? (0) | 2020.07.10 |
AngularJS가 A 태그의 title 속성에 어떻게 바인딩합니까? (0) | 2020.07.10 |
파이썬 생성기 "보내기"기능 목적? (0) | 2020.07.10 |