0

I have two domains running on Apache 2.2 for Windows.

Domain 2 has both secure and non-secure access and works fine.

Domain 1 has the domain and four subdomains. The subdomains redirect to ports on another server on the same network. Each subdomain has its own DNS A record. The domain and subdomains are:

domain1.org media.domain1.org video.domain1.org dsm.domain1.org photo.domain1.org

Domain 1 is not in use. The subdomains all redirect to ports on a NAS.

Only the first virtual host block works. It doesn't matter which of the subdomains is listed first. If media.domain1.org is listed first, media.domain1.org will redirect correctly, but video, dsm, and photo will also redirect to the port assign for media.domain1.org.

Is this an Apache configuration issue or a DNS issue?

Thanks

Edit 1

I added NameVirtualHost this morning and it does nothing. I tried it with both inside and outside IP addresses.

I don't want to upgrade to Apache 2.4. I started with 2.4 and couldn't get it to access the directory for domain2. Using Require All Granted caused the server to not start.

I started with the Proxy statements and they didn't work at all. I do have the proxy modules loaded, but they did not forward to any ports on the NAS.

I will worry about how to access the NAS once I have the separation of the subdomains working.

Here is my virtual host structure:

<VirtualHost *:80>
ServerName media.domain1.org
Redirect / http://domain1.org:7007/
ErrorLog c:/webroot/domain1/logs/error.log
CustomLog c:/webroot/domain1/logs/access.log common
</VirtualHost>

<VirtualHost *:80>
ServerName dsm.domain1.org
Redirect / http://domain1.org:5000/
ErrorLog c:/webroot/domain1/logs/error.log
CustomLog c:/webroot/domain1/logs/access.log common
</VirtualHost>

<VirtualHost *:80>
ServerName video.domain1.org
Redirect / http://domain1.org:6006/
ErrorLog c:/webroot/domain1/logs/error.log
CustomLog c:/webroot/domain1/logs/access.log common
</VirtualHost>

<VirtualHost *:80>
ServerName domain2.com
Serveralias www.domain2.com
ErrorLog c:/webroot/domain2/logs/error.log
CustomLog c:/webroot/domain2/logs/access.log common

DocumentRoot c:/webroot/domain2
    <Directory c:/webroot/domain2>
        Options Indexes FollowSymLinks Includes
    DirectoryIndex index.html index.htm
        AllowOverride All
    Order allow,deny
    Allow from all
    </Directory>
</VirtualHost>

<VirtualHost *:443>

ServerName domain2.com
Serveralias www.domain2.com

  DocumentRoot c:/webroot/domain2
   <Directory c:/webroot/domain2>
    Options Indexes FollowSymLinks Includes
    DirectoryIndex index.html index.htm
     AllowOverride All
    Order allow,deny
    Allow from all
    </Directory>

    ErrorLog c:/webroot/domain2/logs/error.log
    CustomLog c:/webroot/domain2/logs/access.log common

       SSLEngine on
       SSLCertificateFile "c:/apache2/sslkey/certificate.crt"
       SSLCertificateKeyFile "c:/apache2/sslkey/private.key"
       SSLCertificateChainFile "c:/apache2/sslkey/ca_bundle.crt"

</VirtualHost>
yagmoth555
  • 16,300
  • 4
  • 26
  • 48
  • Not sure if this is the reason for problem, but I believe with Apache 2.2 you needed the `NameVirtualHost *:80` directive for vhost use. Try adding that to the top of file. https://httpd.apache.org/docs/2.4/mod/core.html#namevirtualhost Also, you may want to upgrade to Apache 2.4. You don't need it then. https://httpd.apache.org/docs/2.4/upgrading.html – B. Shea Sep 16 '20 at 02:06
  • 1
    BTW if you want to preserve hostnames like media.domain1.org, you could just use proxy directives instead for each one. see https://serverfault.com/a/195831/92023 or v2.2 doc - https://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass – B. Shea Sep 16 '20 at 03:55
  • I don't think 'DNS' is your issue. You can browse the site, correct (if on top)? But also keep in mind if the NAS is on a local network, you should access it that way. Define the local IPs and names in `etc/hosts`, or in a private dns server for your lan(s). I mention this also because you said domain1 is 'not in use'. – B. Shea Sep 16 '20 at 04:05

1 Answers1

0

I finally got this work and I also got the Proxypass working with the same fix.

Adding NameVirtualHost requires an IP address and cannot be done with a wildcard. Once an IP address is specified here the same address also needs to be in and in the Listen statements.

It didn't work with my outside IP address but did work with my inside IP address. So here is the config that works:

NameVirtualHost 192.168.x.xxx:80
Listen 192.168.x.xxx:80
Listen 192.168.x.xxx:443

<VirtualHost 192.168.x.xxx:80>

ServerName media.domain1.org

ProxyPass / http://192.168.x.xxx:7007/
ProxyPassReverse / http://192.168.x.xxx:7007/

</VirtualHost>
roaima
  • 1,567
  • 13
  • 26