| Linode Forum https://forum.linode.com/ |
|
| Multiple IPs on Ubuntu10.04LTS not reflected in HTTP Request https://forum.linode.com/viewtopic.php?f=19&t=8991 |
Page 1 of 1 |
| Author: | aurieli [ Wed Jun 13, 2012 7:08 am ] |
| Post subject: | Multiple IPs on Ubuntu10.04LTS not reflected in HTTP Request |
Hi all, I'm trying to setup two different websites with two different certificates on my Linode (Ubuntu 10.04LTS). To do this on Tomcat, I need two different IP addresses. However, currently, all HTTP requests are going to the same IP address, even if you enter a different IP address in the browser: http://178.79.152.69/test.jsp http://176.58.107.88/test.jsp The code for test.jsp: Code: <p>Java Version:<%= System.getProperty( "java.version" ) %> Any idea how to troubleshoot? I'm a networking newbie, so don't even know at what point the HTTP request header would get the target IP address and name added to it, + have no idea where to start in trying to figure this out. I've setup the two IP addresses in /etc/network/interfaces: Code: # The loopback interface I've also setup the hosts file to point each IP at the correct domain: Code: 127.0.0.1 localhost.localdomain localhost ifconfig gives the following: Code: eth0 Link encap:Ethernet HWaddr fe:fd:b0:3a:6b:58 Rgds, Assaf |
|
| Author: | hoopycat [ Wed Jun 13, 2012 7:02 pm ] |
| Post subject: | Re: Multiple IPs on Ubuntu10.04LTS not reflected in HTTP Req |
Looks fine to me: Code: rtucker@witte:~$ curl http://176.58.107.88/test.jsp |
|
| Author: | aurieli [ Thu Jun 14, 2012 8:00 am ] |
| Post subject: | Re: Multiple IPs on Ubuntu10.04LTS not reflected in HTTP Req |
No - that's precisely the problem. You get the same Local IP and Local Name in both cases: Local IP:178.79.152.69 Local name:www.joli-ciel.com Only the server name is different. What should appear is for 176.58.107.88 is: <p>Java Version:1.6.0_22 <p>Local name:www.moyshele.com <p>Server name:176.58.107.88 <p>Local IP:176.58.107.88 What does appear (exactly the same as for http://www.joli-ciel.com except for the Server Name): <p>Java Version:1.6.0_22 <p>Local name:www.joli-ciel.com <p>Server name:176.58.107.88 <p>Local IP:178.79.152.69 |
|
| Author: | glg [ Thu Jun 14, 2012 9:43 am ] |
| Post subject: | Re: Multiple IPs on Ubuntu10.04LTS not reflected in HTTP Req |
edit: I'm wrong, sorry |
|
| Author: | aurieli [ Thu Jun 14, 2012 11:41 am ] |
| Post subject: | Re: Multiple IPs on Ubuntu10.04LTS not reflected in HTTP Req |
glg wrote: getLocalName and getLocalAddr do not do what you think they do. they look at the local machine, not where the request came to That's unfortunate, because that's what Tomcat uses to resolve the IP address when you tell the connector to do so. From v6.0.35 source code, org/apache/catalina/connector/CoyoteAdapter.java, line 489: Code: if (connector.getUseIPVHosts()) {However, when I dig deeper into the source code to where the request's local name is getting set in the first place, it's being set from socket.getLocalAddress(), on org/apache/catalina/http11/Http11Processor.java, line 1063. Now, according to the java 6.0 javadoc at http://docs.oracle.com/javase/6/docs/ap ... ress%28%29, Socket.getLocalAddress() "Gets the local address to which the socket is bound." So, my interpretation of this is that this is where the request came to, not just some check as to the local machine's IP and name. Otherwise, nobody would be able to get this solution working, which is, however, what is recommended by the Tomcat documentation. http://tomcat.apache.org/tomcat-6.0-doc ... unning_SSL "Finally, using name-based virtual hosts on a secured connection can be problematic." |
|
| Author: | hoopycat [ Thu Jun 14, 2012 6:55 pm ] |
| Post subject: | Re: Multiple IPs on Ubuntu10.04LTS not reflected in HTTP Req |
If you do 'netstat -ntlp', what is the actual address to which it is bound? |
|
| Author: | aurieli [ Fri Jun 15, 2012 6:04 am ] |
| Post subject: | Re: Multiple IPs on Ubuntu10.04LTS not reflected in HTTP Req |
hoopycat wrote: If you do 'netstat -ntlp', what is the actual address to which it is bound? Code: sudo netstat -ntlp |
|
| Author: | hoopycat [ Fri Jun 15, 2012 6:18 am ] |
| Post subject: | Re: Multiple IPs on Ubuntu10.04LTS not reflected in HTTP Req |
You don't seem to have anything bound to port 80...?! It shouldn't be working at all, that much is certain. |
|
| Author: | aurieli [ Fri Jun 15, 2012 6:42 am ] |
| Post subject: | Re: Multiple IPs on Ubuntu10.04LTS not reflected in HTTP Req |
hoopycat wrote: You don't seem to have anything bound to port 80...?! It shouldn't be working at all, that much is certain. Sorry, that's because I have an IPTables rule mapping 8080 to 80 and 8443 to 443, since the tomcat6 account doesn't have access to ports below 1024. Here's the relevent portion: Code: *nat This is called within /etc/network/interfaces via the pre-up command as follows: Code: auto lo |
|
| Author: | hoopycat [ Fri Jun 15, 2012 7:40 pm ] |
| Post subject: | Re: Multiple IPs on Ubuntu10.04LTS not reflected in HTTP Req |
Hmm. If you connect straight to port 8080 instead of 80, does it work as expected? |
|
| Author: | glg [ Sun Jun 17, 2012 10:44 pm ] |
| Post subject: | Re: Multiple IPs on Ubuntu10.04LTS not reflected in HTTP Req |
hoopycat wrote: Hmm. If you connect straight to port 8080 instead of 80, does it work as expected? Using his links from the first post, yes. That means that the mapping ports via iptables is the culprit. You're really not "supposed" to do it that way. You're "supposed" to use a "real" web server like apache with mod_jk or nginx in front of tomcat. and yes, that's all in quotes for a reason, tomcat will work just fine by itself, but occasionally you end up with a scenario like this. You might be able to get the iptables to work by having multiple rules for each IP (ie instead of routing all 443 traffic to 8443, separately route ip1.443 to ip1.8443 and ip2.443 to ip2.8443) Sorry about my previous post, I was off on how those functions work in the context. |
|
| Author: | aurieli [ Mon Jun 18, 2012 4:32 am ] |
| Post subject: | Re: Multiple IPs on Ubuntu10.04LTS not reflected in HTTP Req |
glg wrote: hoopycat wrote: Hmm. If you connect straight to port 8080 instead of 80, does it work as expected? Using his links from the first post, yes. That means that the mapping ports via iptables is the culprit. ... You might be able to get the iptables to work by having multiple rules for each IP (ie instead of routing all 443 traffic to 8443, separately route ip1.443 to ip1.8443 and ip2.443 to ip2.8443) Thanks hoopycat and glg! That solved it. My iptables.conf file now looks like this: Code: -A PREROUTING -p tcp -m tcp --dst 178.79.152.69 --dport 443 -j DNAT --to-destination 178.79.152.69:8443 That being said, I don't quite understand the IPTables OUTPUT rows. I would expect tomcat to be outputting on port 8443, and to be redirected to port 443, but the opposite is written above. But that's a question for another thread! Thanks again! Assaf |
|
| Page 1 of 1 | All times are UTC-04:00 |
| Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |
|