Apache 反向代理端口错误

Apache 反向代理端口错误

我之前问过一个问题,关于如何在我正在运行的服务上获取 SSL 证书。问题在这里提出。

现在我已将域名链接到服务器,并且我可以通过启用 SSL 连接到 Apache。因此,我想启用作为解决方案发布的反向代理。

我跟着本指南将我的 apache 服务器设置为代理。当我尝试启动 apache 服务时,出现以下错误;

● apache2.service - LSB: Apache2 web server
   Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─apache2-systemd.conf
   Active: inactive (dead) since Die 2017-04-25 20:57:59 CEST; 2s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 25802 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS)
  Process: 25377 ExecReload=/etc/init.d/apache2 reload (code=exited, status=0/SUCCESS)
  Process: 25786 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCCESS)

Apr 25 20:57:59 Valhalla apache2[25786]: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:8002
Apr 25 20:57:59 Valhalla apache2[25786]: (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:8002
Apr 25 20:57:59 Valhalla apache2[25786]: no listening sockets available, shutting down
Apr 25 20:57:59 Valhalla apache2[25786]: AH00015: Unable to open logs
Apr 25 20:57:59 Valhalla apache2[25786]: Action 'start' failed.
Apr 25 20:57:59 Valhalla apache2[25786]: The Apache error log may have more information.
Apr 25 20:57:59 Valhalla apache2[25786]:  *
Apr 25 20:57:59 Valhalla apache2[25802]:  * Stopping Apache httpd web server apache2
Apr 25 20:57:59 Valhalla apache2[25802]:  *
Apr 25 20:57:59 Valhalla systemd[1]: Started LSB: Apache2 web server.

这是我的 apache 配置文件;

<VirtualHost *:80>
        Servername novinav.com
        Redirect temp / https://novinav.com/
</VirtualHost>

<VirtualHost *:443>
        ServerAdmin [email protected]
        DocumentRoot /var/www/
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        SSLEngine On
        SSLCertificateFile /etc/ssl/certs/novinav_com.crt
        SSLCertificatekeyFile /etc/ssl/certs/novinav.com.key
        SSLCertificateChainFile /etc/ssl/certs/novinav_com.ca-bundle
        ProxyPreserveHost On
        #servers to proxy the connection, or list of application servers usage
        ProxyPass / http://192.168.0.102:8002/
        ProxyPassReverse / http://192.168.0.102:8002/
        ServerName Valhalla
</VirtualHost>

我认为这与我正在运行的服务已在监听同一端口有关。是否可以让 apache 监听其他端口(例如 8003),然后代理到 8002?

答案1

我找到了解决方案。我从 apache ports.conf 文件中删除了端口 8002,并注释掉了“DocumentRoot /var/www/”行。

现在,当我连接到网站时,我会得到代理服务。

相关内容