Apache 无法让虚拟主机 apache 转发到同一台机器上的另一台主机。差不多好了

Apache Can't get Virtual host apache to forward to another host on same machine. Almost there

您好,感谢您的阅读。

我有一个 windows 2016 服务器 运行 apache。

我正在尝试在一个端口 (8080) 上设置虚拟主机,并且 让它自动将它看到的所有内容转发到主 Apache 主机 (不是虚拟实例?我不清楚如何称呼它) 它位于端口 80

我的配置如下。 我显示服务器正在侦听端口 80 和 8080。 当我转到 80 端口时,我得到了默认的“It works”页面

当我去8080端口的时候 我收到以下错误:

内部服务器错误

Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator at admin@example.com to inform them of the time this error occurred, and the actions you performed just before this error. More information about this error may be available in the server error log.

我查阅了日志,我看到了以下消息

[Thu Sep 24 07:29:16.128967 2020] [proxy:warn] [pid 4860:tid 1076] [client 192.168.50.160:64768] AH01144: No protocol handler was valid for the URL / (scheme 'https'). If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.

我试图在没有任何 ssl/or 加密的情况下执行此操作 下面列出了我的配置和加载模块的副本。 我只包含了基本 conf 文件中已修改的部分

我错过了什么,或者接下来我应该尝试什么来修复?

感谢社区。

听起来您正在使用 https 而不是 http 连接到 192.168.50.160:8080。如果您想使用 HTTPS,则需要设置 :8080 VirtualHost 以正确支持它。

https://www.digitalocean.com/community/tutorials/how-to-create-a-self-signed-ssl-certificate-for-apache-in-ubuntu-16-04

您遇到了一个问题,因为您的 SSL 没有配置,您正在尝试通过 HTTPS,正如 Eliezer 所说,您需要创建您的密钥,为此我使用 LetsEncrypt (certbot ) 但选择取决于你,(我在 Ubuntu)

你的 ports.conf 文件应该有一些看起来像这样的行:

Listen 8080

IfModule ssl_module //add the missing < > around the IfModule
    Listen 443
IfModule

你还需要在将它添加到监听端口后在你的conf中添加<VirtualHost *:443> Your configuration inside the tags</VirtualHost>标签

然后是你的 conf 文件,你需要启用 SSL :

ServerName domain.com
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/domain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/domain.com/privkey.pem

一旦您的 SSL 配置了重写规则,我还建议在 https 上强制重定向:

  RewriteEngine on
  RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [L,QSA,R=permanent]

这个答案是 Apache Ubuntu 配置的基础,但我认为你可以从它到你的 Windows 服务器 Apache 配置