简体   繁体   English

如何通过 AWS 在 Apache 服务器中托管来自同一 IP 地址的多个虚拟主机?

[英]how to host multiple virtual hosts from same IP address in Apache server over AWS?

I want to host two different angular panels over Apache (AWS).我想在 Apache (AWS) 上托管两个不同的 angular 面板。 So I disabled the default 000-default.conf file in etc/apache2/sites-available using a2dissite 000-default.conf and made two files webAdmin.conf and webUIpanel.conf .因此,我使用a2dissite 000-default.conf禁用了etc/apache2/sites-available中的默认000-default.conf文件,并制作了两个文件webAdmin.confwebUIpanel.conf Now my webAdmin.conf has the following configuration现在我的webAdmin.conf有以下配置

<VirtualHost *:80>
   ServerAdmin webmaster@localhost
   DocumentRoot /var/www/html/AngularProjects/getItHomeNow_UI/dist

   ErrorLog ${APACHE_LOG_DIR}/error.log
   CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

and webUIpanel.conf has followingwebUIpanel.conf有以下

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/AngularProjects/getItHomeNow_UserPanel/dist

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Then I used a2ensite to enable both config files and at last sudo systemctl restart apache2 .然后我使用a2ensite来启用这两个配置文件,最后sudo systemctl restart apache2 But one of them working at a time.但他们中的一个同时工作。 I need to disable one to make other work.我需要禁用一个才能使其他工作。 Kindly suggest me where did I go wrong?请建议我 go 哪里错了?

You should add ServerName in your VirtualHost config so Apache can decide which site should get the request.您应该在VirtualHost配置中添加ServerName ,以便 Apache 可以决定哪个站点应该收到请求。 So to apply that to your config it should look like:因此,要将其应用于您的配置,它应该如下所示:

webAdmin.conf

<VirtualHost *:80>
   ServerAdmin webmaster@localhost
   DocumentRoot /var/www/html/AngularProjects/getItHomeNow_UI/dist
   ServerName www.example1.com

   ErrorLog ${APACHE_LOG_DIR}/error.log
   CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

and webUIpanel.conf has followingwebUIpanel.conf有以下

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/AngularProjects/getItHomeNow_UserPanel/dist
    ServerName www.example2.com

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

NOTE: Both ServerName should be valid domains so they resolve to your server or use your /etc/hosts file to point them to your server IP.注意:两个ServerName都应该是有效的域,以便它们解析到您的服务器或使用您的/etc/hosts文件将它们指向您的服务器 IP。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使 ip 指向 AWS 上的其他 ip 和端口(来自两个 apache 虚拟主机) - How to make a ip point to other ip and port (from two apache virtual hosts) on AWS 具有aws专用IP地址的虚拟主机 - virtual host with aws private IP address 如何在 AWS Linux 服务器上实现虚拟主机? - How to implement a Virtual host on AWS Linux Server? 虚拟主机无法使用AWS apache - Virtual host not working AWS apache AWS - 防火墙管理器 - WAF 规则如何阻止来自 IP 地址(无主机名)的请求? - AWS - Firewall Manager - WAF Rules How to block requests from IP address (No Host name)? AWS私有IP地址服务器可以连接到同一VPC中的公共IP地址服务器吗? - Can an AWS private IP address server connect to a public IP address server that is in the same VPC? 无法从AWS实例连接到公共IP地址上的同一实例 - Unable to connect from AWS instance to same instance on public IP address 如何防止 Apache web 服务器接受来自未知主机的请求 - How to prevent Apache web server accepting requests from unknown hosts AWS / Ansible-如何从动态清单中定义的主机跨角色/主机访问事实? - AWS/Ansible - How to access facts across roles/hosts from host defined in dynamic-inventory? 如何从我的 AWS 实例的公共 IP 地址运行 ThingsBoard - How to run ThingsBoard from the public IP address of my AWS instance
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM