Search code examples
apacheportvirtualhostsap-commerce-cloudproxypass

ProxyPass not redirecting to the specified port in Virtualhost


I want to access https://localhost:9002/login.jsp using https://localhost url (without giving the port 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>

This is what I have given in 000-default.conf , Can someone please help me to correct this, I have gone through multiple solutions, but nothing works


Solution

  • Hi Please use the below configuration.

    ..................................................................................

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

    After you make these changes, add the needed modules and restart apache

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