我有一个使用基于名称的虚拟主机的 Apache 服务器。
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/localhost
ServerName localhost.localdomain
ServerAlias localhost.localdomain
ErrorLog logs/localhost_error_log
CustomLog logs/localhost_access_log common
<Directory /var/www/localhost1>
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName localhost1.localdomain
ServerAlias localhost1.localdomain
DocumentRoot /var/www/localhost1
ErrorLog logs/localhost1_error_log
CustomLog logs/localhost1_access_log common
<Directory /var/www/localhost1>
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
当我键入 localhost.localdomain 和 localhost1.localdomain 时,我分别从文件夹 /var/www/localhost 和 /var/www/localhost1 获得正确的页面。但后来我做
ssh -L 0.0.0.0:10080:localhost.localdomain:80 -L 0.0.0.0:10081:localhost1.localdomain:80 localhost
并且 localhost:10080 和 localhost:10081 都导致来自 /var/www/localhost 的答案。尽管通过 SSH 隧道连接,是否可以让 Apache 识别域?