Apache 适用于域,但不能适用于子域

Apache 适用于域,但不能适用于子域

我可以像这样设置代理

NameVirtualHost *:80

<VirtualHost *:80>
   ServerName example.ca

   ProxyPreserveHost On
   ProxyVia Full
   #ProxyRequests off
   # setup the proxy
   <Proxy *>
      Order allow,deny
      Allow from all
   </Proxy>
   ProxyPass        / http://10.0.0.0:123/
   ProxyPassReverse / http://10.0.0.0:123/
</VirtualHost>

但当我像这样包含子域名时则不然

NameVirtualHost *:80

<VirtualHost *:80>
   ServerName dev.example.ca

   ProxyPreserveHost On
   ProxyVia Full
   #ProxyRequests off
   # setup the proxy
   <Proxy *>
      Order allow,deny
      Allow from all
   </Proxy>
   ProxyPass        / http://10.0.0.0:123/
   ProxyPassReverse / http://10.0.0.0:123/
   ErrorLog logs/vhost-error_log
   CustomLog logs/vhost-access_log common
</VirtualHost>

我在网上搜索过,上面的解决方案应该有效,但实际上却不行。有什么想法吗?

编辑按照JoeT 的请求,我已更新上述代码以包含日志,如下所示(vhost_error_log 为空)

虚拟主机访问日志

xxx.xxx.xxx.xxx - - [26/Aug/2015:18:09:58 -0700] "GET / HTTP/1.1" 200 4607
xxx.xxx.xxx.xxx - - [26/Aug/2015:18:09:58 -0700] "GET /assets/application-ffeeed35892b38ff9bfa135564fb0830.css HTTP/1.1" 304 256
xxx.xxx.xxx.xxx - - [26/Aug/2015:18:09:58 -0700] "GET /assets/print-47fe51cdf70398e5e54b544e0f5cc718.css HTTP/1.1" 304 255
xxx.xxx.xxx.xxx - - [26/Aug/2015:18:09:58 -0700] "GET /assets/application-3302fd299e1a3e701974f594a4a76c56.js HTTP/1.1" 304 257
xxx.xxx.xxx.xxx - - [26/Aug/2015:18:09:58 -0700] "GET /assets/logo-ca207549507c811d027110077cf86e90.svg HTTP/1.1" 304 255
xxx.xxx.xxx.xxx - - [26/Aug/2015:18:09:58 -0700] "GET /assets/icon-search-1aee2102ac9ef7c077acce219d346074.png HTTP/1.1" 304 254
xxx.xxx.xxx.xxx - - [26/Aug/2015:18:09:58 -0700] "GET /assets/jquery-ui/ui-bg_flat_75_ffffff_40x100-d20cf782ea2d212335fa15f2ecb5e412.png HTTP/1.1" 304 254
xxx.xxx.xxx.xxx - - [26/Aug/2015:18:09:58 -0700] "GET /?limit=20&offset=0 HTTP/1.1" 200 3394

答案1

我不是通过 apache 服务器来解决问题,而是通过我的域名提供商来解决问题。

您必须登录您的帐户并创建子域名,即

  • john.example.com
  • jane.example.com
  • francis.rutherford.jr.the.third.example.com

我之前只设置了一个本地 Apache 服务器,我的文件捕获了对和 的/etc/hosts请求,并自动将其重定向到 192.0.0.123example.cajohn.example.ca

相关内容