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

Can Apache be configured with a virtual host that doesn't respond at all?

· 52CE 我爱测

Scenario: example.com, a.example.com, and b.example.com all resolve to the IP 1.2.3.4. Apache 2.4.29 on Ubuntu 18.04.1 is configured with several virtualhosts (possibly on non-standard ports); something like: <VirtualHost *:81> S…

问题原文

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

Scenario: example.com, a.example.com, and b.example.com all resolve to the IP 1.2.3.4. Apache 2.4.29 on Ubuntu 18.04.1 is configured with several virtualhosts (possibly on non-standard ports); something like:

<VirtualHost *:81>
  ServerName example.com
  ...
</VirtualHost>

<VirtualHost *:81>
  ServerName a.example.com
  DocumentRoot /var/www/a
  ...
</VirtualHost>

<VirtualHost *:81>
  ServerName b.example.com
  DocumentRoot /var/www/b
  ...
</VirtualHost>

What I'd like is for requests to a.example.com and b.example.com to work as normal virtual hosts, but for requests to example.com (or to 1.2.3.4) to not get any response at all - not a 404 response, not a 5xx response, just nothing at all.

The goal is to have the virtual hosts work normally, but for anything probing the domain or the IP address to not even be aware that an HTTP server is running on that IP.

I've perused the Apache docs for the VirtualHost directive but haven't come up with anything. I've also looked at RFC 7230 and I didn't see anything obvious that would make this scenario impossible - of course a TCP session has to be established before the server knows what the client is requesting, so an attacker would know that something is listening on that port, but as far as I could tell I didn't see anything in the protocol itself that makes the server reveal that it's listening for HTTP before the client makes the request.

I'm not sure what I'm describing is possible, and even if it is, I'm not sure how valuable it would be. Input appreciated.

已采纳解答

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

Perhaps something along the lines of

RewriteEngine on
RewriteRule ^ - [L,redirect=410]

Place this in your default virtual host and every request should return a 410 error.

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

资料来源与适用范围

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

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

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