apache2 vhost负载错误的项目

发布于 2025-02-06 11:02:30 字数 5311 浏览 3 评论 0原文

tl; dr: 我有两个vhost,但第二个(phpmyadmin.conf)确实指向第一个目录。


我有四个vhost:

  • phpmyadmin.conf
  • phpmyadmin_ssl.conf
  • test_api_konfigurator.conf
  • test_api_konfigurator_ssl.conf

/etts/hosts:

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

这两个子域只是我 dns dns server to我的Project Project to project for My Project for My

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

“问题:

Project> 带有此代码exit的“ index.php”(“ hello from phpmyadmin.aws1.company.de”);和和exit(“ test.api.konfigurator.company.company.de ”);在第一行中。

如果我致电https://test.api.konfigurator.company.dehttp://test.api.konfigurator.company.de 然后,我可以从预期看到“ hello test.api.konfigurator.company.de ”。

但是,如果我打电话https://phpmyadmin.aws1.company.dehttp://phpmyadmin.aws1.com.pany.de ,那么我也会得到“ 你好来自test.api.konfigurator.company.de

vhost配置文件

1。 phpmyadmin.conf

    <VirtualHost *:80>
        ServerName phpmyadmin.aws1.company.de
        ServerAdmin [email protected]
        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

    <VirtualHost *:80>
        ServerName phpmyadmin.aws1.company.de
        ServerAdmin [email protected]
        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
  1. test_api_konfigurator.conf

     &lt; virtualHost *:80&gt;
         servername test.api.konfigurator.company.de
         serveradmin 
         DocumentRoot/var/www/company/test.api.konfigurator.company.de/public
    
         &lt; directory/var/www/company/test.api.konfigurator.company.de/public>
                 选项索引遵循Symlinks
                 全部允许
         &lt;/目录&gt;
    
         errorlog $ {apache_log_dir}/test_api_konfigurator_company_error.log
         CustomLog $ {apache_log_dir} /TEST_API_KONFIGURATOR_COMPANY_ACCESS.LOG合并
    
         #从http重定向到https
         重新创新
         重写 ^(。*)$ https://%{http_host} $ 1 [r = 301,l]
     &lt;/virtualhost&gt;
    
     #vim:语法= apache ts = 4 sw = 4 sts = 4 sr noet
     
  2. test_api_konfigurator_ssl.conf

     &lt; virtualHost *:443&gt;
         servername test.api.konfigurator.company.de
         serveradmin网站管理员@localhost
         DocumentRoot/var/www/company/test.api.konfigurator.company.de/public
    
         &lt; directory/var/www/company/test.api.konfigurator.company.de/public>
             选项索引遵循Symlinks
             全部允许
             需要所有授予
         &lt;/目录&gt;
    
         errorlog $ {apache_log_dir}/test_api_konfigurator_company_error.log
         CustomLog $ {apache_log_dir} /TEST_API_KONFIGURATOR_COMPANY_ACCESS.LOG合并
    
         #示例SSL配置
         Sslengine On
         SSLProtocol All -SSLV2
         sslciphersuite高:中:!anull:!md5
         sslcertificatefile“/etc/ssl/certs/company/hoster_cert”
         sslCertificateKeyFile“/etc/ssl/certs/company/hoster_key”
     &lt;/virtualhost&gt;
    
     #vim:语法= apache ts = 4 sw = 4 sts = 4 sr noet
     

详细信息:

我正在使用Ubuntu 22.04 LTS和Apache 2.4.52

TL;DR:
I have two VHOST's but the second one (phpmyadmin.conf) does point to the directory of the first one.


I have four VHOST's:

  • phpmyadmin.conf
  • phpmyadmin_ssl.conf
  • test_api_konfigurator.conf
  • test_api_konfigurator_ssl.conf

/etc/hosts:

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:

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

Problem:

Both project's have a "index.php" with this code exit("hello from phpmyadmin.aws1.company.de"); and respectively 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.

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"

VHOST Config files

1. phpmyadmin.conf

    <VirtualHost *:80>
        ServerName phpmyadmin.aws1.company.de
        ServerAdmin [email protected]
        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

    <VirtualHost *:80>
        ServerName phpmyadmin.aws1.company.de
        ServerAdmin [email protected]
        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
  1. test_api_konfigurator.conf

     <VirtualHost *:80>
         ServerName test.api.konfigurator.company.de
         ServerAdmin [email protected]
         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
    
  2. test_api_konfigurator_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
    

Details:

I am using Ubuntu 22.04 LTS and Apache 2.4.52

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼眸 2025-02-13 11:02:30

我发现了。我的 phpmyadmin_ssl.conf vhost具有端口80,而它需要

443。phpmyadmin_ssl.conf

<VirtualHost *:443>
    ServerName phpmyadmin.aws1.company.de
    ServerAdmin [email protected]
    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

I figured it out. My phpmyadmin_ssl.conf VHOST has Port 80 while it needs 443.

phpmyadmin_ssl.conf

<VirtualHost *:443>
    ServerName phpmyadmin.aws1.company.de
    ServerAdmin [email protected]
    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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文