0

We have a production erp server that has heretofore only been accessible from the LAN. We now have a requirement that parts of it be accessible from outside.

We don't run DNS internally, so all access has just been with 192.168.x.x. The few exceptions for accessing from outside the LAN have been done with whitelisting a few IPs in the router's ACL, and adding a static route to forward traffic hitting the router's static WAN IP.

Right now, I've set up a domain name to hit another of our IPs. There is another static route in the router config to forward traffic for that IP to the same server. I've basically just created another way to hit the same server on 80/443.

What I would like to do now is set up a virtualhost config so that traffic coming in via the new domain will hit a particular folder... domain.com/public for example.

What I'm unsure of, is what, if any, affect this may have on the existing no-virtualhost setup.

TL;DR

If I set up a virtualhost config to point domain-based traffic to a specific folder, do I have to be explicit (set up another virtualhost) about non-domain-based traffic being able to hit the root as it already does now?

3 Answers 3

1

If the domain virtual host is going to use the same IP and Port as the main server, you will need to add a default virtualhost.

You will need to list the default virtual host first in the config file to ensure that it is used when the server is accessed by IP address.

See the 'Main host goes away' box here http://httpd.apache.org/docs/2.4/vhosts/name-based.html#using

2
  • Thanks for the link. Looks like that's the info I need. Additionally, and this may actually be a different question entirely, but is all of this virtualhost config just as pertinent if the server itself does not have a public IP?, but rather a router forwards requests to a LAN IP?
    – JoshP
    Jun 17, 2013 at 14:11
  • Yes it is - Apache doesn't care or know if the configured IPs are public or private. If the virtual host and main server are going to listen on the same IP and port, you will need a default virtual host.
    – Vortura
    Jun 17, 2013 at 14:17
1

Apache does its VirtualHost "decisions" based on where the entries are located in the configuration file. You'll need both entries (one for the VirtualHost and another for *:80/443) and put the VirtualHost one before the catch-all statement.

1

Any domains that resolve to your web server's IP address but are not explicitly listed in a virtual host stanza will be given the content of the first-listed virtual host. So, if you have stanzas for "a.com", "b.com", and "c.com", in that order, and the domain "d.com" resolves to the same IP address, you will get the web pages for the "a.com" domain.

2
  • If I'm reading yours and @Nathan's, answers correctly, you seem to be disagreeing on where the catch-all goes. Am I reading that correctly?
    – JoshP
    Jun 17, 2013 at 13:47
  • You're reading that correctly - in my experience, which may or may not hold true for all versions of Apache, the default, or "catch-all", virtual host ends up being the first one.
    – John
    Jun 17, 2013 at 14:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .