Sean Walsh
Sean Walsh

Reputation: 8344

Pointing a subdomain to another IP via Apache

Is it possible, using only Apache, to point a subdomain at a specific IP address?

We currently have a primary domain(www.example.com) with 250+ subdomains(site1.example.com, site2.example.com, etc). Due to rules regarding an SSL cert, we now have to place www.example.com on it's own IP address(although it still resides on the same server).

The subdomains are currently configured as alias records, so creating 250+ new A records for each subdomain would be a major hassle.

I would love an Apache-based solution to this problem so that I don't have to spend the rest of my day configuring DNS records.

Upvotes: 1

Views: 5537

Answers (1)

You can make mod_proxy pass all requests from one virtual host to another server, which sounds like exactly what you're looking for.

<VirtualHost *:80>
        ServerAdmin [email protected]
        ServerName your.vhost.your.com

        ProxyRequests Off
        <Proxy *>
                Order deny,allow
                Allow from all
        </Proxy>
        ProxyErrorOverride On
        ProxyPass / http://your.realhost.com/
        ProxyPassReverse / http://your.realhost.com/
        <Location />
                Order allow,deny
                Allow from all
        </Location>

</VirtualHost>

You could also do this with mod_rewrite and the [P] option, which can give you a lot more flexibility.

Upvotes: 2

Related Questions