Posts

Showing posts with the label Tomcat

Tomcat Block IP

Change the <Tomcat install path>\conf\context.xml file test in Tomcat 6 and Tomcat 7 Add following context between <Context> tag <Valve className="org.apache.catalina.valves.RemoteAddrValve" deny="<IP Address>"/> Example: <Valve className="org.apache.catalina.valves.RemoteAddrValve" deny="1\.2\.3\.4"/>

Tomcat Knowledge

Program Language(Difference: performance and development cycle) System level:      C / C++ / go  Application level(need VM):      C# / Java / Python / Perl / Ruby Dynamic Website:      Java (servlet, jsp) / Python (Django, Flask) / Perl (module) / Ruby (ror) / PHP webapp server jsp --> tomcat, jboss, jetty php --> php-fpm python --> Django JDK: Java Development Kit JVM: Java Virtual Machine Installation Java Installation 1. install jdk: rpm -ivh jdk...rpm 2. check jdk: /usr/java which java version is using: latest link to which one 3. configure the environment parameter #vim /etc/profile.d/java.sh export JAVA_HOME=/usr/java/latest export PATH=$JAVA_HOME/bin:$PATH #. /etc/profile.d/java.sh #java -version Tomcat Installation 1. uncompress tomcat package: #tar xvf apache-tomcat... -C /usr/local/apache-tomcat-7.0.55 #ln -sv apache-tomcat-7.0.55 tomcat 2. configure the envir...

Update SSL certification

Environment: Windows Server 2008 + Tomcat 7.0 1. Two things need to update:      a. the value of keystorePass in ../conf/server.xml file      b. the keystoreFile file  3. Stop the tomcat service 4. Clean the work foler 5. Start the tomcat service Important notes: the change may impact with old version brower

Tomcat Security

Using /conf/context.xml to ban visiting from some IP address. The  Remote Address Filter  supports the following configuration attributes: Attribute Description className Java class name of the implementation to use. This MUST be set to  org.apache.catalina.valves.RemoteAddrValve . allow A regular expression (using  java.util.regex ) that the remote client's IP address is compared to. If this attribute is specified, the remote address MUST match for this request to be accepted. If this attribute is not specified, all requests will be accepted UNLESS the remote address matches a  deny  pattern. deny A regular expression (using  java.util.regex ) that the remote client's IP address is compared to. If this attribute is specified, the remote address MUST NOT match for this request to be accepted. If this attribute is not specified, request acceptance is governed solely by the accept  attribute. denyStatus HTTP response status code ...

Tomcat Service Install / Uninstall

Windows platform  Install 1. Open command 2. Go to Tomcat folder Example: C:\TomcatPaymark\bin 3. Service install <Tomcat service name> Uninstall 1. Open command 2. Go to Tomcat folder Example: C:\TomcatPaymark\bin 3. Service uninstall <Tomcat service name>

Tomcat Service Update

Tomcat Service update from 6 to 7 If the java JVM which used by Tomcat is 64bit, the tomcat service is 64bit If the java JVM which used by Tomcat is 32bit, the tomcat service is 32bit 1. record the value of initial memory pool and maximum memory pool of Tomcat Service; 2. stop the tomcat service; 3. uninstall the tomcat service and close services windows; 4. delete the tomcat6.exe and tomcat*.exe in tomcat6\bin folder; 5. copy the total item in tomcat7\bin and tomcat7\lib folder to overwrite that in tomcat6\bin and tomcat6\lib; 6. install the tomcat service; 7. change the name of tomcat7w.exe file to the service name; 8. Change the value of initial memory pool and maximum memory pool of Tomcat Service; 9. Change the tomcat\conf\server.xml file from  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" /> to <!-- Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" / --> 10. start t...

Tomcat Setup Oracle Datasource

1. Change configuration files a. C:\TomcatTrans\conf\server.xml i. Change the GlobalNamingResources\Resource: Resource name / url / connectionCacheName ii. Change the Service\Connector: address b. C:\TomcatTrans\conf\web.xml i. change the web-app\resource-ref: res-ref-name c. C:\TomcatTrans\conf\context.xml i. Change the Context\ResourceLink: global d. All the application in webapps need to change Example:  i. find thor.properties files  ii. Change the dataSourceName 2. Change the java property of Tomcat 3. Run script in database: ALTER SYSTEM SET SEC_CASE_SENSITIVE_LOGON = FALSE; 4. Disable the firewall of application server and database serve 5. Co py msvcr71.dll from java’s bin directory to tomcat’s bin folder. 6. Check the tomcat version to define 32 or 64. Use the attachment tool PESnoop.exe command: PESnoop tomcat6.exe /pe_dh Tomcat 8 needs at least JRE 7 Tomcat 7 needs at least JRE 6

Tomcat JMX Monitor

Add the following context into the Tomcat Service Properties / Java tab / Java Options -Djava.rmi.server.hostname=<ip address> -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=<port> -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false Example -Djava.rmi.server.hostname=192.168.204.40 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8585 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false Monitor tools: 1. Install jdk1.8  2. Go to bin folder 3. Double click jconsole.exe 4. Choose Remote Process 5. Inpu the IP Address and port of the tomcat server which you want to monitor For example: 192.168.204.40:8585

Tomcat Config

Add following parameters into Tomcat application, we can use C:\Program Files (x86)\Java\jdk1.8.0\bin\jconsole.exe to monitor the status of JVM -Djava.rmi.server.hostname=<IP address> -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8011 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -XX:MaxPermSize=256m Unpack the war file set in conf/server.xml unpackWARs="true" autoDeploy="true"