-2

CentOS 7.x

Apache (httpd)

External NAT: 10.140.x.x

Internal IP: 10.105.x.x

When trying to reach the apache server on https://10.140.x.x, it tries to resolve the hostname in the lower left corner of firefox. This won't work because we can't control DNS for the NAT network. How do I configure Apache to listen on an IP that obviously doesn't exist on any interface of the box?

I've tried editing /etc/httpd/conf/httpd.conf

ServerName 10.140.x.x:80

and

/etc/httpd/conf.d/ssl.conf

<VirtualHost _default_:443>

# General setup for the virtual host, inherited from global configuration
DocumentRoot "/var/www/html"
ServerName 10.140.x.x:443

But these edits don't seem to do anything. We are able to reach the site on the same internal network.

4
  • You say "When trying to reach the apache server on 10.140.x.x, it tries to resolve the hostname" but that's not a hostname, it's an IP address, so no resolution is required.
    – Rumbles
    Mar 15, 2019 at 14:08
  • No. The browser will show the hostname of the machine in the lower left corner when trying to access the site: Trying to reach hostname . . .
    – Johnny Doe
    Mar 15, 2019 at 14:25
  • @Rumbles How are you so sure it's an IP address? When I click that link Chromium sends out AAAA queries for 10.140.x.x, so at least Chromium consider it to be a domain name rather than an IP address.
    – kasperd
    Mar 15, 2019 at 15:18
  • @kasperd That's because it has alphabetic characters in it. Mar 15, 2019 at 15:47

2 Answers 2

0

I haven't used apache in a number of years, so excuse me if this isn't completely correct (I used nginx, it's really good, you should give it a look). As I stated in my comment, you're not using a hostname in your request, so it shouldn't be trying to do any DNS lookup (unless you've omitted that info).

I would also suggest using curl to test instead of a web browser. If you do:

curl 10.10.11.1 -vvv

It should tell you exactly what is going on during the request, using a web browser can make it harder to understand issues.

In answer to your question:

How do I configure Apache to listen on an IP that obviously doesn't exist on any interface of the box?

Why would you want to? If you did this, it would be listening for traffic to come in on an address that isn't ever going to get to apache, so it will never serve that content.

If you're hoping to point traffic at the public address of your NAT gateway, and for that traffic to reach your web server, that won't work either, NAT doesn't know where to route your web request. NAT gateways are generally used so your host can speak to the outside world, and their returning traffic is able to find the host it came from. You don't use a NAT gateway to route incoming traffic to a given host, that's what port forwarding/redirection is for.

Maybe some extra context about your infrastructure and what you're trying to achieve will make it easier to find you an appropriate solution?

1
  • We have an internal network ip that has a natted ip to another internal network (but that has internet access). Apache (WordPress w/plugins) that expect to reach various CDNs to receive data to render pages. This isn't possible within the internal network since the browser expects to reach things like jquery.com and so on. We can reach the nat ip which is forwarding to the internal ip and you can tell because the title of the page is loaded but it appears to hang trying to figure out what "hostname" is which it won't because DNS (for that "outside" network) has no concept of this hostname
    – Johnny Doe
    Mar 15, 2019 at 14:54
0

This was solved by going to Wordpress > General Settings > changing WordPress Address URL to:

https://10.140.x.x

Really this appears to be more of a WordPress issue than Apache. Thank you for the help guys. The site also loads significantly faster that the browser can reach out to the external sources.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.