apache2 VirtualHost在新端口上不能正常工作
问题描述:
我刚刚在我的Ubuntu机器上安装了LAMP,当我访问它时它工作正常。我想在另一个端口(端口1337)上添加虚拟主机,该端口转到目录/var/www/flag-1/
。为了做到这一点,我采取下列步骤:apache2 VirtualHost在新端口上不能正常工作
cd /etc/apache2/sites-available/
- 创建的文件
flag-1.conf
- 添加的内容:
<VirtualHost *:1337> ServerAdmin [email protected] DocumentRoot /var/www/flag-1/ ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
- 在
/etc/apache2/ports.conf
的顶部,在Listen 80
之后,一个ddedListen 1337
- 做
a2ensite flag-1.conf
- 重装上阵阿帕奇
service apache2 restart
当我和端口1337访问该网站启用虚拟主机的网站,它只是加载无限。默认端口仍然正常工作,并且我没有启用UFW。没有错误,在access.log
或error.log
中没有任何出色的。
任何帮助表示赞赏。谢谢!
答
想通了 - 我使用的是Google云端平台,他们阻止了端口1337,我只好通过它手动允许TCP。
如果你想知道,该命令是
gcloud compute firewall-rules create allow-port-1337 --allow tcp:1337 --description="Allow port 1337 to be accessed"