How to change/redirect Apache Tomcat port number

On Thai (ภาษาไทย). your can read this blog

Change Port Number
  1. Locate {TOMCAT_HOME}\conf\
  2. Edit server.xml
  3. Find Section Connector which not in comments! such as
<Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443" />
  1. Change Port to <YOUR REQUIREMENT> such as 8888
<Connector port="8888" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443" />
  1. Restart tomcat server.

Redirect Port

Requirement: The Legacy App hard code for connect server with port 9090, so I want to redirect request from <IP>:9090 to <IP>:8888

  1. Locate {TOMCAT_HOME}\conf\
  2. Edit server.xml
  3. Find Section Connector which not in comments! such as
<Connector port="8888" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443" />
  1. Copy Connector Section and Change Port = 9090 and redirectPort = 8888
<!--redirect request from <IP>:9090 to <IP>:8888 -->
<Connector port="9090" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8888" />

<!--Main Setting-->
<Connector port="8888" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443" />
  1. Restart tomcat server.

Discover more from naiwaen@DebuggingSoft

Subscribe to get the latest posts sent to your email.