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

How to create dummy virtual host in Apache to avoid cache poisoning

· 52CE 我爱测

To avoid cache poisoning, I was asked to create a dummy virtual host on my Apache Web Server, so that all the forged requests(which are not actually related to my application) will go to the dummy virtual host. Below is my curren…

问题原文

原帖链接 · balaji · CC BY-SA 3.0

To avoid cache poisoning, I was asked to create a dummy virtual host on my Apache Web Server, so that all the forged requests(which are not actually related to my application) will go to the dummy virtual host.

Below is my current virtual host:

<VirtualHost *:*>
   DocumentRoot "cache location"
   ServerName myappname
</virtualHost>

I'm trying to create a dummy virtual host with Server name as * and with a different cache location. This is what I tried:

<VirtualHost *:*>
   DocumentRoot "another cache location"
   ServerName *
</virtualHost>

How can I test that my dummy virtual host configuration works, and do I need to modify my configuration?

已采纳解答

原帖链接 · HBruijn · CC BY-SA 3.0

As far as I know setting * as the ServerName will only match a literal * as the hostname and that does not do not the intended wildcard matching...

Your dummy virtual host , the VirtualHost entry that will respond to any and all unqualified requests that don't match any of the specific domain names that are explicitly configured, should by the first VirtualHost entry in your configuration.

<VirtualHost *:80>
  # This is the first and will handle anything that is not example.[com | net | org] 
  ...
</VirtualHost> 
<VirtualHost *:80>
  ServerName example.com
  ...
</VirtualHost> 
<VirtualHost *:80>
  ServerName example.net
  ...
</VirtualHost> 
<VirtualHost *:80>
  ServerName example.org
  ...
</VirtualHost>

The second part of this answer has a suitable setup for the default VirtualHOST: https://serverfault.com/a/662356/37681

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

资料来源与适用范围

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

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

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