[英]apache2 vhost loads wrong project
TL;DR: I have two VHOST's but the second one (phpmyadmin.conf) does point to the directory of the first one. TL;DR:我有两个 VHOST,但第二个(phpmyadmin.conf)确实指向第一个的目录。
I have four VHOST's:我有四个 VHOST:
127.0.0.1 localhost
127.0.0.1 test.api.konfigurator.company.de
127.0.0.1 phpmyadmin.aws1.company.de
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
The two subdomains are just CNAME records from my DNS server to my project server:这两个子域只是从我的DNS 服务器到我的项目服务器的 CNAME 记录:
phpmyadmin.aws1.company.de. 300 CNAME ec2-xxx-xxx-xxx-xxx.eu-central-1.compute.amazonaws.com
test.api.konfigurator.company.de. 300 CNAME ec2-xxx-xxx-xxx-xxx.eu-central-1.compute.amazonaws.com
Both project's have a "index.php" with this code exit("hello from phpmyadmin.aws1.company.de");
两个项目都有一个带有此代码的“index.php”
exit("hello from phpmyadmin.aws1.company.de");
and respectively exit("hello from test.api.konfigurator.company.de");
并分别
exit("hello from test.api.konfigurator.company.de");
in the first line.在第一行。
If I call https://test.api.konfigurator.company.de
or http://test.api.konfigurator.company.de
then I get to see " hello from test.api.konfigurator.company.de " as expected.如果我调用
https://test.api.konfigurator.company.de
或http://test.api.konfigurator.company.de
然后我会看到“ hello from test.api.konfigurator.company.de ” .
But if I call https://phpmyadmin.aws1.company.de
or http://phpmyadmin.aws1.company.de
then I also get " hello from test.api.konfigurator.company.de "但是如果我打电话给
https://phpmyadmin.aws1.company.de
或http://phpmyadmin.aws1.company.de
那么我也会得到“你好来自 test.api.konfigurator.company.de ”
1. phpmyadmin.conf 1.phpmyadmin.conf
<VirtualHost *:80>
ServerName phpmyadmin.aws1.company.de
ServerAdmin black@company.de
DocumentRoot /usr/share/phpmyadmin
<Directory /usr/share/phpmyadmin>
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/phpmyadmin_error.log
CustomLog ${APACHE_LOG_DIR}/phpmyadmin_access.log combined
# Redirect from http to https
RewriteEngine On
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
2. phpmyadmin_ssl.conf 2.phpmyadmin_ssl.conf
<VirtualHost *:80>
ServerName phpmyadmin.aws1.company.de
ServerAdmin black@company.de
DocumentRoot /usr/share/phpmyadmin
<Directory /usr/share/phpmyadmin>
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/phpmyadmin_error.log
CustomLog ${APACHE_LOG_DIR}/phpmyadmin_access.log combined
# Example SSL configuration
SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5
SSLCertificateFile "/etc/ssl/certs/company/hoster_cert"
SSLCertificateKeyFile "/etc/ssl/certs/company/hoster_key"
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
test_api_konfigurator.conf test_api_kconfigurator.conf
<VirtualHost *:80> ServerName test.api.konfigurator.company.de ServerAdmin black@company.de DocumentRoot /var/www/company/test.api.konfigurator.company.de/public <Directory /var/www/company/test.api.konfigurator.company.de/public> Options Indexes FollowSymLinks AllowOverride All </Directory> ErrorLog ${APACHE_LOG_DIR}/test_api_konfigurator_company_error.log CustomLog ${APACHE_LOG_DIR}/test_api_konfigurator_company_access.log combined # Redirect from http to https RewriteEngine On RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L] </VirtualHost> # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
test_api_konfigurator_ssl.conf test_api_kconfigurator_ssl.conf
<VirtualHost *:443> ServerName test.api.konfigurator.company.de ServerAdmin webmaster@localhost DocumentRoot /var/www/company/test.api.konfigurator.company.de/public <Directory /var/www/company/test.api.konfigurator.company.de/public> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/test_api_konfigurator_company_error.log CustomLog ${APACHE_LOG_DIR}/test_api_konfigurator_company_access.log combined # Example SSL configuration SSLEngine on SSLProtocol all -SSLv2 SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5 SSLCertificateFile "/etc/ssl/certs/company/hoster_cert" SSLCertificateKeyFile "/etc/ssl/certs/company/hoster_key" </VirtualHost> # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
I am using Ubuntu 22.04 LTS and Apache 2.4.52我正在使用 Ubuntu 22.04 LTS 和 Apache 2.4.52
I figured it out.我想到了。 My phpmyadmin_ssl.conf VHOST has Port 80 while it needs 443.
我的phpmyadmin_ssl.conf VHOST 有端口 80,而它需要 443。
<VirtualHost *:443>
ServerName phpmyadmin.aws1.company.de
ServerAdmin black@company.de
DocumentRoot /usr/share/phpmyadmin
<Directory /usr/share/phpmyadmin>
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/phpmyadmin_error.log
CustomLog ${APACHE_LOG_DIR}/phpmyadmin_access.log combined
# Example SSL configuration
SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5
SSLCertificateFile "/etc/ssl/certs/company/hoster_cert"
SSLCertificateKeyFile "/etc/ssl/certs/company/hoster_key"
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.