Reputation: 13
I'm using a VM on Google Compute Engine, I chose a g1-small machine.
I installed tomcat server. The server do run, but I can't reach it on my web browser.
I also installed httpd and I can reach port 80 on my browser, but not 8080
This are my open ports:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1180/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1198/master
tcp6 0 0 :::22 :::* LISTEN 1180/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1198/master
tcp6 0 0 127.0.0.1:8005 :::* LISTEN 11470/java
tcp6 0 0 :::8080 :::* LISTEN 11470/java
tcp6 0 0 :::80 :::* LISTEN 11319/httpd
This is my tomcat.service file:
[Unit]
Description=Tomcat 8.5 servlet container
After=network.target
[Service]
Type=forking
User=tomcat
Group=tomcat
Environment="JAVA_HOME=/usr/lib/jvm/jre"
Environment="CATALINA_BASE=/opt/tomcat/apache-tomcat-8.5.56"
Environment="CATALINA_HOME=/opt/tomcat/apache-tomcat-8.5.56"
Environment="CATALINA_PID=/opt/tomcat/apache-tomcat-8.5.56/temp/tomcat.pid"
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"
ExecStart=/opt/tomcat/apache-tomcat-8.5.56/bin/startup.sh
ExecStop=/opt/tomcat/apache-tomcat-8.5.56/bin/shutdown.sh
[Install]
WantedBy=multi-user.target
I already added port 8080 to firewall with the command
firewall-cmd --zone=public --permanent --add-port=8080/tcp
firewall-cmd --reload
But when I list the firewall settings I get this
trusted (active)
target: ACCEPT
icmp-block-inversion: no
interfaces: eth0
sources:
services: http https
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
Upvotes: 1
Views: 402
Reputation: 4461
To solve your issue you should configure GCP Firewall to allow ingress connections to your Tomcat server.
Have a look at the documentation Configuring Firewall Rules and follow instruction Creating a firewall ingress rule via Console or via command line:
gcloud compute firewall-rules create tomcat-server-allow-ingress --direction=INGRESS --priority=1000 --network=default --action=ALLOW --rules=tcp:8080 --source-ranges=0.0.0.0/0 --target-tags=tomcat-server
I'd recommend you to replace 0.0.0.0/0
with your IPs and use network tags to apply your rule to your VM instance directly:
gcloud compute instances add-tags tomcat-server --zone=europe-west3-a --tags=tomcat-server
Upvotes: 1