无法发布到 NameVirtualHost

无法发布到 NameVirtualHost

使用

apache2ctl -t -D DUMP_VHOSTS

节目

VirtualHost configuration:
*:443                  is a NameVirtualHost
     default server api.mysite.com (/etc/apache2/sites-enabled/mysite-ssl.conf:3)
     port 443 namevhost api.mysite.com (/etc/apache2/sites-enabled/mysite-ssl.conf:3)
             wild alias *api.mysite.com
     port 443 namevhost testapi.mysite.com (/etc/apache2/sites-enabled/mysite-ssl.conf:70)
             wild alias *testapi.mysite.com
     port 443 namevhost admin.mysite.com (/etc/apache2/sites-enabled/mysite-ssl.conf:146)
             wild alias *admin.mysite.com
     port 443 namevhost beta.mysite.com (/etc/apache2/sites-enabled/mysite-ssl.conf:179)
             wild alias *beta.mysite.com
     port 443 namevhost mysite.com (/etc/apache2/sites-enabled/mysite-ssl.conf:217)
             wild alias *.mysite.com

我的站点测试版有目录并且运行良好。行政只是 Location 块中的代理传递,并且工作正常。这三个是页面 URL。 api测试API是没有目录、只有位置的代理通道。所有 443 都在 VirtualHost *:443 下的同一个文件中。

<VirtualHost *:443>
  ServerAdmin [email protected]
  ServerName testapi.mysite.com
  ServerAlias *testapi.mysite.com

  SSLEngine on
  SSLProtocol all -SSLv2 -TLSv1
  SSLCipherSuite ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM

  SSLCertificateFile /etc/apache2/ssl/acc6af27250e2edc.crt
  SSLCertificateKeyFile /etc/apache2/ssl/mysite.key
  SSLCertificateChainFile /etc/apache2/ssl/gd_bundle-g2-g1.crt

  <Location />
    ProxyPass http://localhost:8889/
    ProxyPassReverse http://localhost:8889/
  </Location>

  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

https POST 请求测试API甚至不会显示在 Apache 的访问日志中。404 未找到。

这是从 Nginx 配置翻译过来的,确实有效。我希望在 Apache 中看到它。

知道为什么 POST 请求可能无法连接吗?

答案1

已解决。上面的方法确实有效。我以为 Location / 是罪魁祸首,或者可能是我忽略了在配置中添加的内容。我实际上得到的是

<Location /another-path>
    ProxyPass http://localhost:3003/another-path
    ProxyPassReverse http://localhost:3003/another-path
</Location>

位于通用位置上方。请求另一条路失败了,并尝试了错误上游不存在的路径。日志没有帮助。显然,我应该在问题中包含完整的配置。

当然,顺序很重要。位置 /另一条路径,以下通用的 (/) 起作用了。在 Nginx 中情况正好相反。

相关内容