request.getRemoteHost() returns IP address instead of FQDN











up vote
1
down vote

favorite












I am designing a servlet in which I would like to determine the fully qualified domain name (FQDN) of the client. I am attempting to use javax.servlet.HttpServletRequest.getRemoteHost() in order to get the hostname. When running the application on Apache Tomcat as a standalone server, request.getRemoteHost() works as I would hope, returning the FQDN of the client. However, when running the application with the Apache Httpd server as a frontend and mod_jk as the connector, request.getRemoteHost() always returns the ip address of the client instead of the FQDN.



I have tried the following two configuration options in an attempt to solve this problem.




  1. In Apache Tomcat's server.xml I have set enableLookups="true"

  2. In Apache Httpd's httpd.conf, I have set HostnameLookups On


Still request.getRemoteHost() returns the client's ip address instead of it's FQDN.



Is there a configuration option that will allow my servlet's request.getRemoteHost() method return the client's FQDN when running Apache Tomcat with Apache Httpd, as it does when it is running with just Apache Tomcat?



My environment is RHEL 7.5 with Apache Httpd server 2.4.6 and Apache Tomcat 8.5










share|improve this question









New contributor




Bill T is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • one IP can have many many FQDNs associated with it. What are you trying to accomplish? You may be better off checking PTR records for the IP retrieved (reverse DNS records)
    – ivanivan
    yesterday










  • I'm trying to get ANY hostname. You are correct, I would be better off with reverse dns, but this is a third party application and I cannot modify the source code. I'm just trying to make the existing code work (if it is possible).
    – Bill T
    yesterday










  • Check this forum post out - particularly the part about the RFC that defines the HTTP connection stuff... coderanch.com/t/81745/application-servers/…
    – ivanivan
    yesterday















up vote
1
down vote

favorite












I am designing a servlet in which I would like to determine the fully qualified domain name (FQDN) of the client. I am attempting to use javax.servlet.HttpServletRequest.getRemoteHost() in order to get the hostname. When running the application on Apache Tomcat as a standalone server, request.getRemoteHost() works as I would hope, returning the FQDN of the client. However, when running the application with the Apache Httpd server as a frontend and mod_jk as the connector, request.getRemoteHost() always returns the ip address of the client instead of the FQDN.



I have tried the following two configuration options in an attempt to solve this problem.




  1. In Apache Tomcat's server.xml I have set enableLookups="true"

  2. In Apache Httpd's httpd.conf, I have set HostnameLookups On


Still request.getRemoteHost() returns the client's ip address instead of it's FQDN.



Is there a configuration option that will allow my servlet's request.getRemoteHost() method return the client's FQDN when running Apache Tomcat with Apache Httpd, as it does when it is running with just Apache Tomcat?



My environment is RHEL 7.5 with Apache Httpd server 2.4.6 and Apache Tomcat 8.5










share|improve this question









New contributor




Bill T is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • one IP can have many many FQDNs associated with it. What are you trying to accomplish? You may be better off checking PTR records for the IP retrieved (reverse DNS records)
    – ivanivan
    yesterday










  • I'm trying to get ANY hostname. You are correct, I would be better off with reverse dns, but this is a third party application and I cannot modify the source code. I'm just trying to make the existing code work (if it is possible).
    – Bill T
    yesterday










  • Check this forum post out - particularly the part about the RFC that defines the HTTP connection stuff... coderanch.com/t/81745/application-servers/…
    – ivanivan
    yesterday













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I am designing a servlet in which I would like to determine the fully qualified domain name (FQDN) of the client. I am attempting to use javax.servlet.HttpServletRequest.getRemoteHost() in order to get the hostname. When running the application on Apache Tomcat as a standalone server, request.getRemoteHost() works as I would hope, returning the FQDN of the client. However, when running the application with the Apache Httpd server as a frontend and mod_jk as the connector, request.getRemoteHost() always returns the ip address of the client instead of the FQDN.



I have tried the following two configuration options in an attempt to solve this problem.




  1. In Apache Tomcat's server.xml I have set enableLookups="true"

  2. In Apache Httpd's httpd.conf, I have set HostnameLookups On


Still request.getRemoteHost() returns the client's ip address instead of it's FQDN.



Is there a configuration option that will allow my servlet's request.getRemoteHost() method return the client's FQDN when running Apache Tomcat with Apache Httpd, as it does when it is running with just Apache Tomcat?



My environment is RHEL 7.5 with Apache Httpd server 2.4.6 and Apache Tomcat 8.5










share|improve this question









New contributor




Bill T is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I am designing a servlet in which I would like to determine the fully qualified domain name (FQDN) of the client. I am attempting to use javax.servlet.HttpServletRequest.getRemoteHost() in order to get the hostname. When running the application on Apache Tomcat as a standalone server, request.getRemoteHost() works as I would hope, returning the FQDN of the client. However, when running the application with the Apache Httpd server as a frontend and mod_jk as the connector, request.getRemoteHost() always returns the ip address of the client instead of the FQDN.



I have tried the following two configuration options in an attempt to solve this problem.




  1. In Apache Tomcat's server.xml I have set enableLookups="true"

  2. In Apache Httpd's httpd.conf, I have set HostnameLookups On


Still request.getRemoteHost() returns the client's ip address instead of it's FQDN.



Is there a configuration option that will allow my servlet's request.getRemoteHost() method return the client's FQDN when running Apache Tomcat with Apache Httpd, as it does when it is running with just Apache Tomcat?



My environment is RHEL 7.5 with Apache Httpd server 2.4.6 and Apache Tomcat 8.5







apache-httpd dns tomcat






share|improve this question









New contributor




Bill T is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Bill T is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited yesterday









Jeff Schaller

37k1052121




37k1052121






New contributor




Bill T is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Nov 30 at 21:43









Bill T

112




112




New contributor




Bill T is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Bill T is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Bill T is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • one IP can have many many FQDNs associated with it. What are you trying to accomplish? You may be better off checking PTR records for the IP retrieved (reverse DNS records)
    – ivanivan
    yesterday










  • I'm trying to get ANY hostname. You are correct, I would be better off with reverse dns, but this is a third party application and I cannot modify the source code. I'm just trying to make the existing code work (if it is possible).
    – Bill T
    yesterday










  • Check this forum post out - particularly the part about the RFC that defines the HTTP connection stuff... coderanch.com/t/81745/application-servers/…
    – ivanivan
    yesterday


















  • one IP can have many many FQDNs associated with it. What are you trying to accomplish? You may be better off checking PTR records for the IP retrieved (reverse DNS records)
    – ivanivan
    yesterday










  • I'm trying to get ANY hostname. You are correct, I would be better off with reverse dns, but this is a third party application and I cannot modify the source code. I'm just trying to make the existing code work (if it is possible).
    – Bill T
    yesterday










  • Check this forum post out - particularly the part about the RFC that defines the HTTP connection stuff... coderanch.com/t/81745/application-servers/…
    – ivanivan
    yesterday
















one IP can have many many FQDNs associated with it. What are you trying to accomplish? You may be better off checking PTR records for the IP retrieved (reverse DNS records)
– ivanivan
yesterday




one IP can have many many FQDNs associated with it. What are you trying to accomplish? You may be better off checking PTR records for the IP retrieved (reverse DNS records)
– ivanivan
yesterday












I'm trying to get ANY hostname. You are correct, I would be better off with reverse dns, but this is a third party application and I cannot modify the source code. I'm just trying to make the existing code work (if it is possible).
– Bill T
yesterday




I'm trying to get ANY hostname. You are correct, I would be better off with reverse dns, but this is a third party application and I cannot modify the source code. I'm just trying to make the existing code work (if it is possible).
– Bill T
yesterday












Check this forum post out - particularly the part about the RFC that defines the HTTP connection stuff... coderanch.com/t/81745/application-servers/…
– ivanivan
yesterday




Check this forum post out - particularly the part about the RFC that defines the HTTP connection stuff... coderanch.com/t/81745/application-servers/…
– ivanivan
yesterday















active

oldest

votes











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






Bill T is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f485266%2frequest-getremotehost-returns-ip-address-instead-of-fqdn%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes








Bill T is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















Bill T is a new contributor. Be nice, and check out our Code of Conduct.













Bill T is a new contributor. Be nice, and check out our Code of Conduct.












Bill T is a new contributor. Be nice, and check out our Code of Conduct.
















Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f485266%2frequest-getremotehost-returns-ip-address-instead-of-fqdn%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Accessing regular linux commands in Huawei's Dopra Linux

Can't connect RFCOMM socket: Host is down

Kernel panic - not syncing: Fatal Exception in Interrupt