One, Tomcat and Nginx configuration
/etc/nginx/conf.d/default.conf
location/nsx{
Proxy_pass HTTP://NSX;
Proxy_connect_timeout 30s;
Proxy_read_timeout 30s;
Proxy_send_timeout 30s;
Proxy_set_header Host $host;
Proxy_set_header X-real-ip $remote _addr;
}
Upstream nsx{
Ip_hash;
Server 10.15.21.134:8095;
2, Tomcat configuration Server.xml, 3 ports.
Second, the project attention point
/opt/skyform/skyform-cmdb/webapps/cmdbapi
1, Tomcat under the war package after decompression folder name must be with the Nginx configuration file
/etc/nginx/conf.d/default.conf definition Consistent
location/cmdbapi{
2, http://physical; is the project package name
Http://localhost:8080/cmdbapi/network/test
Network/test in the control layer code settings.
3. If the war package is Root.war (without the version number) into Tomcat
No project name, HTTP URL access,
You need to set/nsx/network/test in the control class of the engineering code
(to include the project URL)
Http://localhost:8080/nsx/network/test
4, before the URL access test, you must ensure that Tomcat boot normal, Linux must look at the Tomcat log file
Locating logs
/var/log/nginx/error.log
/tomcat/logs/catalina.log
Third, access the rest interface using the Restclient tool
1, get general Get query interface, do not set body
2. Post Access
Set the message header Content-type=application/json
Send body set JSON format
{
"AccountId": "Jyjtest1"
}
Response Body:json Format
- {
- " msg": "Lstalledge is empty." ,
- " networkid": "",
- " Success": "fail"
- }
Restclient accessing SPRINGMVC Java Engineering interface