I have come up with the following brief Bash script in an effort to quickly view port configurations from Apache and Tomcat on a RHEL or CentOS Application Server I am familiar with, but would like to make the command more applicable to other Linux hosts with Tomcat and Apache deployments to help me in troubleshooting. Bear in mind that it’s only intended to be a quick overview of statically bound ports, redirects, includes, and SSL implementations. Does anyone with more Apache and Tomcat experience have any suggestions for modifications to this?
while IFS= read -r FILE
do
printf -- '----------------------------------------nFILE: %snn' "$FILE"
if [[ $FILE == *.conf ]]
then
cat "$FILE" |grep -v '#' |grep "[^#]*SSL.*|Proxy|VirtualHost|Include" || echo " *No port info*"
printf 'n'
else
cat "$FILE" |sed '/<!--/,/-->/d' |awk '/<Connector port/,//>/' | grep . || echo " *No port info*"
printf 'n'
fi
done < <(find / -type f -iname server.xml -o -iname httpd.conf -not -path "*/doc/*")