【问题标题】:Apache: two domains on the same server with different portsApache:同一服务器上的两个域具有不同的端口
【发布时间】:2021-07-25 18:09:09
【问题描述】:

我是这个东西的新手,如果我在做一个愚蠢的问题,请原谅我。我有一个运行在端口 80 上的 vue 应用程序在 SSL 上运行良好(比如 www.domain.com 和 domain.com)。

现在我需要我的 springboot 应用程序,该应用程序在端口 8443 上运行,也可以通过安全连接访问(比如在 api.domain.com 上),但我不太清楚我做错了什么...... 如果我不包括第二个虚拟主机,我可以访问 api,但只能使用 http ...另外,当我输入 api.domain.com 时,它也会进入 domain.com 起始页面。当我包含第二个虚拟主机时,我什至无法访问 domain.com。

<IfModule mod_ssl.c>
<VirtualHost *:443>
    
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

ServerName www.domain.com
Include /etc/letsencrypt/options-ssl-apache.conf
ServerAlias domain.com
ProxyPreserveHost On
SSLCertificateFile /etc/letsencrypt/live/domain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/domain.com/privkey.pem
</VirtualHost>
<VirtualHost *:443>
    ServerAdmin webmaster@localhost
    ServerName api.domain.com

    Include /etc/letsencrypt/options-ssl-apache.conf
    ServerAlias api.domain.com
    SSLCertificateFile /etc/letsencrypt/live/domain.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/domain.com/privkey.pem
    ProxyPreserveHost On
        ProxyPass / http://127.0.0.1:8443/
        ProxyPassReverse / http://127.0.0.1:8443/
</VirtualHost>
</IfModule>

【问题讨论】:

    标签: apache virtualhost


    【解决方案1】:

    发现:有一些 apache 模块需要激活。刚刚做到了

    sudo a2enmod proxy
    sudo a2enmod proxy_http
    

    一切都像魅力一样。

    【讨论】:

      猜你喜欢
      • 2022-01-02
      • 1970-01-01
      • 2018-12-28
      • 2016-10-06
      • 2019-01-21
      • 2012-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多