request.getLocatHost() Different with port 80 vs mod_jk

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

request.getLocatHost() Different with port 80 vs mod_jk

Jerry Malcolm
I'm taking Christopher's advice to remove httpd and mod_jk out of my
process and go straight to Tomcat on port 80.  At this point the only
thing I've done is stop the httpd service and change the Connector port
to 80.  I'm running on my local machine.  I have a hosts entry set to
"local.aaaaa.com 127.0.0.1", and I use the url http://local.aaaaa.com to
access the site.   When I use the old setup with httpd/mod_jk, a call to
request.getLocalHost() returns "local.aaaaa.com" as expected.  After
doing nothing but changing to go straight to TC on port 80,
getLocalHost() returns 127.0.0.1.    request.getRequestURL() still gives
me the http://local.aaaaa.com.  Theoretically, I could change my code to
parse getRequestURL() instead of getLocalHost() to get the real host
name.  But I don't really want to do that without understanding why I'm
seeing the change.  Is there something else I need to add to the config
file when moving to direct port 80 off of mod_jk?  Ideas? BTW... I'm on
TC 9.0.16.

Thanks.

Jerry


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: request.getLocatHost() Different with port 80 vs mod_jk

Christopher Schultz-2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Jerry,

On 7/18/20 18:29, Jerry Malcolm wrote:
> I'm taking Christopher's advice to remove httpd and mod_jk out of
> my process and go straight to Tomcat on port 80.  At this point the
> only thing I've done is stop the httpd service and change the
> Connector port to 80.  I'm running on my local machine.  I have a
> hosts entry set to "local.aaaaa.com 127.0.0.1", and I use the url
> http://local.aaaaa.com to access the site.   When I use the old
> setup with httpd/mod_jk, a call to request.getLocalHost() returns
> "local.aaaaa.com" as expected.

getLocalAddr or getLocalName? getLocalHost isn't in the API.

> After doing nothing but changing to go straight to TC on port 80,
> getLocalHost() returns 127.0.0.1.    request.getRequestURL() still
> gives me the http://local.aaaaa.com.  Theoretically, I could
> change my code to parse getRequestURL() instead of getLocalHost()
> to get the real host name.  But I don't really want to do that
> without understanding why I'm seeing the change.  Is there
> something else I need to add to the config file when moving to
> direct port 80 off of mod_jk?  Ideas? BTW... I'm on TC 9.0.16.
Wild guess:

Tomcat doesn't bother to resolve the "127.0.0.1" into a hostname when
you call getLocalName, but the AJP connector will accept this hostname
from the reverse proxy... and httpd DOES resolve it for you.

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl8UP6oACgkQHPApP6U8
pFgzKg/9Hj67KnafXpQymCy8wSicDf8u1QvXNxdIN8poiLWSrwml3HwlBLdibYRH
MPqZOrmV+WFTEzTxjhREb3qUxQkcN2rEWFp4fYZmMS5VB8gyOBVMcCp381SNbHUa
pX7Nftr0ofCznhSQZmuCnBrR8+HGNNoucYLrfTPCMhuMrja+JtYNhrC+pQnTO6ZI
ZBVKxoTuUhxQltVleqotC1bISNq70W6gG0CImi/k435b+ujK6qSEGVUBdLs1Q6RZ
db/a2TaWjXlBi3yRQqRT852tpeo/kSAapzJX41wzKuQeDiysM0+scJmq8lrERMdO
mDugoePcxpNpOgCUsa8YznPro4Snt0MZM9fApO/PTNfzHlftS2FMQEidmFNl+03i
zkbQ/TNcRa2pKM5ivvqnqIJF1aJWPwD5Qfw7E+h+ovaVMxftOyB86z2/SxGqG5un
TbMZZlJqp2PqchuTUpCuEtnOWYdzGmNnUSxPJhNpxguQ80BQj2EeGr2dX626+2VA
56tBqK97HXgmRzJoa5JAJJx+AYKBEenSDW3HlWVoHm2Lshni7P9rqPVGzUROEV6/
McYDww9ukuw6jyz2owepFwVmym3q2s/apBdnTEbJUL4GR48bwI3O6iwogE7FLgGD
aLqbYYnlOf5KsdvzHFtnqKQcERHCZDDhKE+a05ijLNho3JHqZG0=
=pKGS
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]