Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
622 views
in Technique[技术] by (71.8m points)

curl - Tomcat manager remote deploy script

I'm writing a shell script to auto deploy/undeploy using the tomcat manager.

Following the instructions on http://tomcat.apache.org/tomcat-6.0-doc/manager-howto.html#Deploy_A_New_Application_Remotely, I use curl for my deployment

curl --anyauth -u username:pwd -d path=/something -d war=file:target/someWar.war https://someurl.com/manager/deploy

And I get the response saying HTTP method POST is not supported by this URL.

So I change my curl to be a get using -G

curl --anyauth -u username:pwd -G -d path=/something -d war=file:target/someWar.war https://someurl.com/manager/deploy

I get a response of FAIL - Failed to deploy application at context path /something and it seems to be looking for the file locally on the server instead of my machine. There are pluings which do remote deploy without having to scp the file over so I'm wondering what I'm missing.

I'm currently out of ideas (I don't see any other option on the tomcat manager configuration page).

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Providing an update to this question.

Tomcat 7 has changed it's manager API.

Please refer to: Manager commands

Following new URL pattern :

http://{host}:{port}/manager/text/{command}?{parameters}

Example

curl -T "myapp.war" "http://manager:manager@localhost:8080/manager/text/deploy?path=/myapp&update=true"

Security

Keep in mind the server must be able to accept your remote IP. This is a sample configuration:

<Context privileged="true" antiResourceLocking="false"
         docBase="${catalina.home}/webapps/manager">
  <Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="127.0.0.1" />
</Context>

This is an optional setting and isn't required but having Cross domain role and proper manager credentials is a must.

Tomcat 8 - the same rules apply as Tomcat 7. Same commands.

Here is a full documentation:

http://tomcat.apache.org/tomcat-8.0-doc/manager-howto.html


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...