apachesslwildflyvirtualhostvirtual-hosts

Redireting Https requests on Apache for Wildfly


I am using Apache Virtual Hosts to run multiple websites. I am using apache in Front and this apache is redirecting the url request to the wildfly Server.

My Apache Configuration is working fine for http request using below code

<VirtualHost *:80>
    ServerAdmin webmaster@mysitedemo.com
    ServerName mysitedemo.com
    ServerAlias www.mysitedemo.com
    <Proxy *>
            Order deny,allow
            Allow from all
    </Proxy>
    ProxyRequests Off
    ProxyPreserveHost On
    ProxyPass / http://localhost:8080/
    ProxyPassReverse / http://localhost:8080/
    ErrorLog "logs/mysitedemo-error_log"
    CustomLog "logs/mysitedemo-access_log" common
</VirtualHost>

Now I also want to handle Https Request for that i have added below code in vhosts file

<VirtualHost *:443>
    ServerAdmin webmaster@mysitedemo.com
    ServerName mysitedemo.com
    ServerAlias www.mysitedemo.com
    <Proxy *>
            Order deny,allow
            Allow from all
    </Proxy>
    ProxyRequests Off
    ProxyPreserveHost On
    ProxyPass / https://localhost:8443/
    ProxyPassReverse / https://localhost:8443/
    ErrorLog "logs/mysitedemo-error_log"
    CustomLog "logs/mysitedemo-access_log" common
</VirtualHost>

But it is not working properly giving me, the following error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at webmaster@mysitedemo.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.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

I have setup the SSL on Wildfly server. Do I need to buy separate SSL for Apache as well or can I use the same SSL on Apache? If yes, then please explain how I can do that?


Solution

  • Redireting Https requests on Apache for Wildfly

    If one augments the information in your question with the additional information in the comments one can see that you don't actually redirect the client as you claim in various places in your question. In case of a redirect the server will tell the client to ask a different server. What you do instead here is forwarding where your Apache works as reverse proxy and forwards the request from the client to the Wildfly server and sends the response from the Wildfly back to the client.

    Since in this case the client is only directly interacting with the Apache server this Apache server will do the TLS handshake if HTTPS is used by the client. This means that the Apache must have the appropriate certificates configured and SSL enabled. The Apache will then terminate the original HTTPS connection from the client. Since you have configured ProxyPass to a HTTPS url Apache will then do another HTTPS connection to the proxied Wildfly server. And, from the perspective of the client it does not matter if the Wildfly server is HTTPS enabled or not - all what matters is how to access the Apache server.