tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier>
Subject Re: redirect request from 8080 to port 80
Date Wed, 15 May 2013 16:15:48 GMT
Ognjen Blagojevic wrote:
> André,
> On 15.5.2013 15:38, André Warnier wrote:
>> As far as I understand here, we are not talking about a proxy situation,
>> we are talking about Iptables, which does not proxy, it just modifies
>> packets.
>> So the URL that Tomcat gets from the 1st request line does not contain a
>> hostname[:port}.
> According to RFC2616 (Section 5.1.2), client may send absolute URI or 
> absolute path. Majority of clients will send absolute path when talking 
> to the server.

Absolute *path*, yes. They MUST do that if they are talking to "this" server.

But HTTP 1.1 clients will only send an absolute URI (including hotsname[:port] when 
talking to a proxy.

In this case we are not in a proxy situation, so the request line will not contain 

>> But yes, the Host header will contain a port, if different from the
>> default 80.
> Right.
>> So is that where Tomcat picks it up here, despite receiving the request
>> on the (different) port of the Connector ?
> Yes. You may take a look at 
> AbstractHttp11Processor.parseHost(MessageBytes). If the host header is 
> not set (e.g. client uses HTTP 1.0), Tomcat will set port to the one 
> read from endpoint configuration. If the client uses HTTP 1.1, where 
> host header is mandatory, Tomcat will read host header. If there is a 
> port specified in the value of the host header it will be read. If there 
> is no port specified in the host header that Tomcat will assume port 80 
> for HTTP and port 443 for HTTPS.

Yes, that it will be read seems normal.
But that it would be logged as the port on which the request was received, seems a bit 
less intuitive.
But if that is what happens..

I find it less intuitive because of the Javadoc of HttpServletRequest.getLocalPort :

int getLocalPort()

     Returns the Internet Protocol (IP) port number of the interface on which the request

was received.

         an integer specifying the port number
         Servlet 2.4

So that is the interface (the Connector), not the port number mentioned in the Host header.

>> Or is there just something not clear about the OP's configuration ?
> I have no explanation why the OP is using iptables prerouting inversly 
> of what is their common usage with Tomcat.

Agreed.  But maybe the OP has a reason for running Tomcat on port 8080, but still doesn't

want clients to have to specify a non-standard HTTP port in their URLs.

> -Ognjen
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message