在本地主机上运行的Express服务器的Apache配置VirtualHost

时间:2019-06-02 08:56:50

标签: apache express ssl localhost virtualhost

为了使这个东西正确配置,我正在努力几天。

我要达到的目标是在端口443上运行带ssl的apache虚拟主机,以服务Angular应用程序的dist /文件夹。 效果很好,但是我还需要在同一台机器上的localhost:3000上运行Express服务器。

所以我试图像这样通过代理传递:

<VirtualHost *:443>
  ServerAdmin me@mail.com
  ServerName sub.domain.com
  DocumentRoot /var/www/folder/dist
  SSLEngine on
  SSLCertificateFile      /etc/ssl/certs/apache.cer
  SSLCertificateKeyFile   /etc/ssl/private/apache.key
  ProxyPass /api http://localhost:3000/
  ProxyPassReverse /api http://localhost:3000/
</VirtualHost>

但这是行不通的,当我呼叫https://sub.domain.com/api/get/some/data时,结果呼叫仅为get/some/data。 (也许RewriteRule在这里可以提供帮助?)

然后我尝试仅为Express应用程序构建VirtualHost:

<VirtualHost *:3001>
  ServerAdmin me@mail.com
  ServerName sub.domain.com
  SSLEngine on
  SSLCertificateFile      /etc/ssl/certs/apache.cer
  SSLCertificateKeyFile   /etc/ssl/private/apache.key
  ProxyPass / http://localhost:3000/
  ProxyPassReverse / http://localhost:3000/
</VirtualHost>

但是https://sub.domain.com.io:3001/get/some/datahttp://sub.domain.com.io:3001/get/some/data都没有带来任何结果,它只是超时而已。

我要达到的目标是通过https(现在是这样)和不带ssl的localhost上的express服务器运行角度站点,并通过apache代理到外部。

该如何配置?

0 个答案:

没有答案
相关问题