bind9 DNS – Configuring VirtualHosts with Apache2 on Debian

Apache2binddebiandomain-name-systemvirtualhost

My goal is to host various sites (local virtualhosts) on my apache webserver in the LAN of my enterprise (Debian 9 server).

So that:

  • openproject.myenterprise.local => /opt/openproject
  • wiki.myenterprise.local => /var/www/location/wiki
  • etc.

I configured virtualhosts on my apache2 webserver with

  • /etc/apache2/sites-available/openproject.conf ServerName openproject.myenterprise.local
  • /etc/apache2/sites-available/000-main-static-site.conf ServerName vmDebDevSrv1.myenterprise.local ServerAlias salado.myenterprise.local
  • /etc/apache2/sites-available/001-wiki.conf ServerName wiki.myenterprise.local

Now its working with a local configuration in /etc/hosts

172.16.12.171 openproject.myenterprise.local
172.16.12.171 wiki.myenterprise.local

When I add the DNS resolution with bind9 it doesn't work anymore. I guess it is because of the incapacity of my server to relay the FQDN I use.

  • When I ping or put the url into my browser wiki it works but gives me the main directory of my webserver not the wiki virtualhost

Edit: ping wiki gives me:

ws1: ~$ ping wiki
PING ns1.myenterprise.local (172.16.10.174): 56 data bytes
64 bytes from 172.16.10.174: icmp_seq=0 ttl=64 time=0.282 ms
^C--- ns1.myenterprise.local ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.282/0.325/0.368/0.043 ms

/edit

  • When I ping wiki.myenterprise.local it doesn't work ping: unknown host, Edit: nslookup works with FQDN /Edit

My /etc/resolv.conf

domain myenterprise.local
search myenterprise.local
nameserver 172.16.12.174
nameserver 172.16.12.1
nameserver ...

/etc/bind/db.myenterprise.local

$TTL|   604800
@|      IN|     SOA|    ns1.myenterprise.local. root.vmDebDevSrv1.myenterprise.local. (
|       |       |       20181129|       ; Serial
|       |       |        604800||       ; Refresh
|       |       |         86400||       ; Retry
|       |       |       2419200||       ; Expire
|       |       |        604800 )|      ; Negative Cache TTL

;Name server information
@|      IN|     NS|     ns1.myenterprise.local.

;IP Address of Domain Name Server(DNS) setted on line above
ns1|    IN|     A|      172.16.12.174

;CNAME Records
vmDebDevSrv1|   IN|     CNAME|  ns1.myenterprise.local.
wiki|   IN|     CNAME|  vmDebDevSrv1.myenterprise.local.
openproject|    IN|     CNAME|  vmDebDevSrv1.myenterprise.local.

;tried too with 
;wiki|   IN|     A  172.16.12.174
;openproject|   IN|     A  172.16.12.174

What Am I missing?!!! I thought the path would be short-name=>DNS=>FQDN=>Apache2=>well page returned

So I guess its impossible to get

Best Answer

When I ping or put the url into my browser wiki it works but gives me the main directory of my webserver not the wiki virtualhost.

When you only enter wiki in your browser window, I would say that even though the OS adds the search domains when trying to perform a DNS lookup, the Host header sent in the HTTP request is just what you've put in the browser window, i.e. Host: wiki. To make that work, put in a ServerAlias wiki in your Apache configuration.

When I ping wiki.myenterprise.local it doesn't work.

Can you paste the output of your ping commands? Some troubleshooting steps to consider:

  • Can you resolve your FQDNs? Please provide proof that you can.
  • Can you resolve using only the host names, i.e. is the search domain correctly being applied to your DNS queries? Please provide proof that you can.
  • Do they all resolve to the correct IP address(es)? Please provide proof.
  • If ping doesn't work, check your routing and firewall rules.
Related Topic