【发布时间】:2023-03-31 12:31:01
【问题描述】:
我有以下名为 000-default.conf 的 Apache 虚拟主机配置文件
<VirtualHost *:80>
ServerName mydomain.com
DocumentRoot /var/www/mydomain.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =mydomain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<VirtualHost *:80>
ServerName api.mydomain.com
ProxyPreserveHost On
ProxyPass / http://xxx.xx.xx.xx:3000/
ProxyPassReverse / http://xxx.xx.xx.xx:3000/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
我面临以下 2 个问题,我不确定问题是在 Apache 方面还是在 DNS 方面:
- 当我访问 www.mydomain.com 时,我看到了我应该访问的页面 正在看到,但如果我尝试在搜索栏中仅输入 domain.com,我 出现错误 - 此网站无法提供安全连接
- 当我访问 api.mydomain.com 时,我看到了正确的页面 应该看到但是当我尝试 www.api.mydomain.com 时,我得到了 应该在 www.mydomain.com 上的页面。
谁能说明这是由于 Apache 配置错误还是我需要在 DNS 上做些什么?
【问题讨论】:
-
看起来像一个配置问题(请参阅apache 标签说明,该标签说明将这些问题声明为 stackoverflow 上的题外话。另外:您提供端口 80 配置,以及有关“安全连接”的错误消息,在您提供的配置 sn-p 中,您甚至没有配置您希望以特定方式表现的所有主机名(例如
www.api...) -
@OlafKock 嗯,你为什么说我什至没有配置我想要以特定方式表现的所有主机名?使用 ServerName api.mydomain.com 的第二个虚拟主机应该处理 API。
-
您说在
api.*上一切正常,但在www.api.*上却不是。我没有看到www.api.*的任何配置。我没有看到任何 https
标签: apache virtualhost