我在www.example.com注册了一个域名(例如example.com)godaddy.com,并使用AWS进行托管。
我安装了ubuntu(t2.medium)apache服务器。我在Docker中的项目安装了LAMP、ELK、Node、React和Postgres。所有东西都可以在本地系统上使用直接端口工作。在我的项目中几乎没有打开的端口。
- example.com:3000 react应用程序[前端]
- example.com:5601千纸鹤应用程序
- example.com:5050 postgradmin应用程序
- example.com/radius应用程序[后台]
- example.com:8080 phpmyadmin应用程序
我想要的URL是:
- example.com:3000React应用程序[前端] =〉http://example.com
- example.com:5601 kibana应用程序=〉http://kibana.example.com
- example.com:5050 postgradmin应用程序=〉http://postgradmin.example.com
- example.com/radius后台管理] =〉返回首页
- example.com:8080 phpmyadmin应用程序=〉http://phpmyadmin.example.com
我试过几种方法,但都不管用。
通过添加单独的配置文件,尝试在apache上使用反向代理,例如
默认.conf
<VirtualHost *:80>
ServerAdmin contact@example.com
DocumentRoot "/var/www/html"
ServerName example.com
<Directory "/var/www/html/">
AllowOverride all
</Directory>
</VirtualHost>
kibana.配置文件
Listen 5601
<VirtualHost *:5601>
ServerAdmin contact@example.com
ServerName kibana.example.com
</VirtualHost>
网页管理配置
Listen 5050
<VirtualHost *:5050>
ServerAdmin contact@example.com
ServerName pgadmin.example.com
</VirtualHost>
当我在EC2上运行docker-compose up
时,http://example.com/radius工作正常。但其他的则不行(例如http://kibana.example.com)。但如果直接尝试使用端口(例如example.com:5601),它可以工作。但我想使用子域,而不是带端口的域。
怎么做呢?
反向代理我尝试了描述中提到的,但它不能正常工作
1条答案
按热度按时间kcrjzv8t1#
首先,如果您希望您的域可以公开访问,您需要为所有域创建记录。
其次,如果您只想通过域访问而不想通过端口访问,则应该创建多个虚拟主机块,只侦听端口80,然后根据服务器接收到的域进行路由
示例可在here中找到