大网数据广告活动
服务器运维问答

bind9 DNS server and virtualhosts apache2: getting to work multiple virtualhost like foo.myenterprise.com

· 52CE 我爱测

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/…

问题原文

原帖链接 · Philippe Gachoud · CC BY-SA 4.0

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

已采纳解答

原帖链接 · Tommiie · CC BY-SA 4.0

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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-11-13)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。