Pergunta

I have a Tomcat 7 server running on a CentOS6 VM (bridged network mode, we'll say the IP is 1.2.3.4) and am trying (and unable) to access it from the host machine. I can access the resource test (a file containing "Hello, world!") from the VM with

# wget 1.2.3.4:8080/test/

...and it comes down fine. If I try the same command from the host, either it fails (connection refused), or it connects and then spits out a

Read error (Connection reset by peer) in headers.
Retrying.

It will try once or twice more, with the last one being "connection refused".

When the connection is refused, nothing shows up in the access log. When I get a read error, the request shows up in the access log with a response code of 200. Which response I get switches back and forth intermittently.

This is the connector for 8080 in server.xml:

<Connector port="8080" protocol="HTTP/1.1"
    connectionTimeout="20000"
    redirectPort="8443" />

The fact that Tomcat sees any of the requests from the host makes me pretty sure it's not the firewall, but here's the VM's iptables file:

# Generated by iptables-save v1.4.7 on Wed May  7 10:27:30 2014
*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT 
-A INPUT -s 1.2.3.0/24 -p tcp -m tcp --dport 8080 -j ACCEPT 
-A INPUT -i lo -j ACCEPT 
-A INPUT -p icmp -j ACCEPT 
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT 
COMMIT
# Completed on Wed May  7 10:27:30 2014

Is there a server configuration I'm missing, or something that might be causing the inconsistencies in the responses?

Foi útil?

Solução 2

I wasn't able to find the real cause of the problem - I shut down my VM and host machine, restarted both, restarted Tomcat, and was then able to reach 1.2.3.4:8080/test/ from the host.

I did narrow the problem down to the host (I think): I tried firing up a different VM and saw the same behaviour trying to reach the Tomcat server on that from the host. My host iptable rules don't appear to have changed since the reboot, however.

Update: The same behaviour described in the question returned the next day. I switched from using a bridged network adapter to NAT on eth0 and a host-only network on eth1 with static IPs. Everything's running smoothly now (with no further changes to iptables).

Outras dicas

...and it comes down fine. If I try the same command from the host, either it fails 
(connection refused), or it connects and then spits out a ...

It looks like firewall, iptables have such thing like: allow few packets to pass through, even if they are disabled(should be filtered out)

I suggest to watch with tcpdump in VM, which real source ip is for requests like tcpdump -n -i br0 port 8080

it possible that your host iptable rules or routing table playing with your requests

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top