ProxyPass 未重定向到 Virtualhost 中的指定端口

问题描述

我想使用 https://localhost url 访问 https://localhost:9002/login.jsp(不提供端口 9002)

<VirtualHost *:443>
    SSLEngine on

    SSLCertificateFile  /etc/ssl/certs/ssl-cert-snakeoil.pem
    SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

    ProxyPreserveHost On
    ProxyPass         / https://localhost:9002/
    ProxyPassReverse  / https://localhost:9002/
</VirtualHost>

这是我在 000-default.conf 中给出的,有人可以帮我纠正这个问题,我已经尝试了多种解决方案,但没有任何效果

解决方法

您好,请使用以下配置。

..................................... ……………………………………………………………………………………………………………………………………………………………………………………

<VirtualHost *:443> 
  ProxyPreserveHost On
  ProxyRequests Off
  ServerName www.example.com
  ServerAlias example.com
  ProxyPass / http://localhost:8080/example/
  ProxyPassReverse / http://localhost:8080/example/
</VirtualHost> 

进行这些更改后,添加所需的模块并重新启动 apache

sudo a2enmod proxy && sudo a2enmod proxy_http && sudo service apache2 restart