To change the port number W4N is listening on from 58080 to different port such as 80, do the following:
- In an XML editor, open the Watch4net server.xml file in the following directory:
<APG>/ Web-Servers/Tomcat/Default/conf
- Find the main Connector element in the server.xml file, and change the Connector port attribute from 58080 to the desired port number (see following "Port change considerations" section). The following shows the main Connector element section:
<Connector port="58080" protocol="HTTP/1.1"
connectionTimeout="20000"
compression="off" compressableMimeType="text/"
redirectPort="58443" URIEncoding="UTF-8" />
- Restart Tomcat service.
Port change considerations
In Linux, ports below 1024 are reserved for privileged users like root. To have the Watch4net Tomcat service running by the Watch4net apg user on a port lower than 1024 such as port 80, you must set Tomcat as root user by adding apg.user=root to unix-service.properties file in the in "Main Service Properties" section. The unix-service.properties file is found in the following Watch4net directory:
<APG>/ Web-Servers/Tomcat/Default/conf
Alternatively, you can use the iptables command in Linux and a technique known as port relaying or net filtering to "relay" Port 80 tcp connections to port 58080. The syntax for this command is as follows:
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 58080
(replace eth0 with your actual interface name if it is different)
To add a redirect message:
1. Create ROOT folder
mkdir /opt/APG/Web-Servers/Tomcat/Default/webapps/ROOT
2. Create index.html
vi /opt/APG/Web-Servers/Tomcat/Default/webapps/ROOT/index.html
3. Paste the following content (sample message in body):
<html>
<head>
<title>Redirect</title>
<META http-equiv="refresh" content="0;URL=/APG/">
</head>
<body>Please wait while redirecting...
</body>
</html>
4. Change permissions, owner & group to ROOT folder:
chmod 755 /opt/APG/Web-Servers/Tomcat/Default/webapps/ROOT/
chown R apg:apg /opt/APG/Web-Servers/Tomcat/Default/webapps/ROOT/
5. Restart tomcat
/opt/APG/bin/./manage-modules.sh service restart tomcat