OS : Ubuntu
My domain name requires port 8080 in the URL . I tried changing server.xml file in the Tomcat folder to port 80 . Then I did tomcat restart , but it did not work.
<Connector port=“80” protocol=“HTTP/1.1” connectionTimeout=“20000” redirectPort=“8443” />
Can you please let me know where I need to make the change.
Thanks.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
This question was answered by @mpatidar:
It’s workable solution. Let the port 8080 by default in server.xml
Run : sudo /sbin/iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
This redirect traffic from port 80 to 8080 (default in tomcat) in Ubuntu 14.04 it is not possible to set the default port to 80 in server.xml.
To make this persistent: sudo apt-get install iptables-persistent
This package allows you to save iptables rules previously entered. Be sure to answered yes (save the current settings)
This question was answered by @mpatidar:
It’s workable solution. Let the port 8080 by default in server.xml
Run : sudo /sbin/iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
This redirect traffic from port 80 to 8080 (default in tomcat) in Ubuntu 14.04 it is not possible to set the default port to 80 in server.xml.
To make this persistent: sudo apt-get install iptables-persistent
This package allows you to save iptables rules previously entered. Be sure to answered yes (save the current settings)
This question was answered by @mpatidar:
It’s workable solution. Let the port 8080 by default in server.xml
Run : sudo /sbin/iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
This redirect traffic from port 80 to 8080 (default in tomcat) in Ubuntu 14.04 it is not possible to set the default port to 80 in server.xml.
To make this persistent: sudo apt-get install iptables-persistent
This package allows you to save iptables rules previously entered. Be sure to answered yes (save the current settings)
Guys, after a while trying to find a solution without interfering in iptables as suggested @arunm8489 , I found a solution. The solution proposed by @manandharbishes is ok but we need one more step by changing /etc/default/tomcat8 From: #AUTHBIND=no to AUTHBIND=yes
In the comments of this file, they say:
For you guys, this is the script I followed:
$ nano /etc/tomcat8/server.xml
change the port from 8080 to 80
$ touch /etc/authbind/byport/80
$ chmod 500 /etc/authbind/byport/80
$ nano /usr/share/tomcat8/bin/setenv.sh
CATALINAOPTS=”-Djava.net.preferIPv4Stack=true”
$ nano /usr/share/tomcat8/bin/startup.sh
exec authbind –deep “$PRGDIR”/”$EXECUTABLE” start “$@”
$ nano /etc/default/tomcat8
AUTHBIND=yes
Thats it!
It’s workable solution. Let the port 8080 by default in server.xml
Run : sudo /sbin/iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
This redirect traffic from port 80 to 8080 (default in tomcat) in Ubuntu 14.04 it is not possible to set the default port to 80 in server.xml.
To make this persistent: sudo apt-get install iptables-persistent
This package allows you to save iptables rules previously entered. Be sure to answered yes (save the current settings)
It’s workable solution. Let the port 8080 by default in server.xml
Run : sudo /sbin/iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
This redirect traffic from port 80 to 8080 (default in tomcat) in Ubuntu 14.04 it is not possible to set the default port to 80 in server.xml.
To make this persistent: sudo apt-get install iptables-persistent
This package allows you to save iptables rules previously entered. Be sure to answered yes (save the current settings)
It’s workable solution. Let the port 8080 by default in server.xml
Run : sudo /sbin/iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
This redirect traffic from port 80 to 8080 (default in tomcat) in Ubuntu 14.04 it is not possible to set the default port to 80 in server.xml.
To make this persistent: sudo apt-get install iptables-persistent
This package allows you to save iptables rules previously entered. Be sure to answered yes (save the current settings)
It’s workable solution. Let the port 8080 by default in server.xml
Run : sudo /sbin/iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
This redirect traffic from port 80 to 8080 (default in tomcat) in Ubuntu 14.04 it is not possible to set the default port to 80 in server.xml.
To make this persistent: sudo apt-get install iptables-persistent
This package allows you to save iptables rules previously entered. Be sure to answered yes (save the current settings)
1.First install tomcat 8 from source (Assumed to be installed in /opt/tomcat) 2. Install authbind Wget https://s3.amazonaws.com/aaronsilber/public/authbind-2.1.1-0.1.x86_64.rpm
4 Make IPv4 the default (authbind does not currently support IPv6). To do so, create the file TOMCAT/bin/setenv.sh with the following content: (here in /opt/tomcat/bin/setenv.sh) CATALINA_OPTS=“-Djava.net.preferIPv4Stack=true”
OLD: exec “$PRGDIR”/“$EXECUTABLE” start "$@
[[If you already got a setenv.sh file in /usr/share/tomcat7/bin with CATALINA_OPTS, you have to use : export CATALINA_OPTS=“$CATALINA_OPTS -Djava.net.preferIPv4Stack=true”]]
6.Now make changes in /opt/tomcat/conf/server.xml file to change port(for 443 we have to crete keystroke file.follow the document for it)
7.Now restart service #service tomcat restart
To enable ssl: 1.create keystroke
keytool -genkey -alias svr1.tecadmin.net -keyalg RSA -keystore /etc/pki/keystore
Sample o/p Enter keystore password: Re-enter new password: What is your first and last name? [Unknown]: Arun What is the name of your organizational unit? [Unknown]: Web What is the name of your organization? [Unknown]: Technology What is the name of your City or Locality? [Unknown]: Delhi What is the name of your State or Province? [Unknown]: Delhi What is the two-letter country code for this unit? [Unknown]: IN Is CN=arun, OU=Web, O=Technology, L=Delhi, ST=Delhi, C=IN correct? [no]: yes
Enter key password for (RETURN if same as keystore password): Re-enter new password:
Create CSR:
keytool -certreq -keyalg RSA -alias svr1.tecadmin.net -file svr1.csr -keystore /etc/pki/keystore
Install the root certificate:
keytool -import -alias root -keystore /etc/pki/keystore -trustcacerts -file root.crt
Install the issued certificate:
keytool -import -alias svr1.tecadmin.net -keystore /etc/pki/keystore -trustcacerts -file svr1.tecadmin.net.crt
<Connector port=“8443” protocol=“HTTP/1.1” connectionTimeout=“20000” redirectPort=“8443” SSLEnabled=“true” scheme=“https” secure=“true” sslProtocol=“TLS” keystoreFile=“/etc/pki/keystore” keystorePass=“password” /> 4.restart tomcat service #service tomcat restart
hi, Without interfering iptables iam able to perform this task in ubuntu.But in centos/Redhat iam not able to find a solution without using iptables.Any help plz…
Thanks for the valuable post
I performed the following operations , still I am port 80 is not listened to . Any help , much appreciated.
Steps I : Changed the server.xml <Connector port=“80” protocol=“HTTP/1.1” connectionTimeout=“20000” redirectPort=“8443” />
Step 2 : Make port 80 available to authbind : touch /etc/authbind/byport/80 chmod 500 /etc/authbind/byport/80
Step 3 : create the file TOMCAT_HOME/bin/setenv.sh with the following content: CATALINA_OPTS=”-Djava.net.preferIPv4Stack=true”
Step 4: Change startup.sh: exec authbind –deep “$PRGDIR”/”$EXECUTABLE” start “$@”
OLD: exec “$PRGDIR”/”$EXECUTABLE” start “$@”
Thanks.
I am unable to find Catalina.out file . I see only files like catalina.2015-08-28.log etc. Tried commands like find , this file does not exist.
When i hit the URL , the webpage error is that , it is " Unable to Connect " .
What is the process though ? Do i only need to change server.xml file which i have mentioned above ?
Thanks for the support.
First thing you should do when debugging, is check your logs? What does it say? You get any error? You say: It did not work. What does not work,there are different ways something can’t work…