Context
I need to put a Java application server (http port 8080, https 8181) behind IIS 7.5 (http port 80, https 443) on Windows Server 2008.
Steps
I have used IIS ARR
module for enabling Proxy in order to route some requests to the Java application server. I have also created some URL Rewrite
rules for the purpose. Using http
, everything works fine.
The rule used states that when the requested URL matches the pattern (MyAppContextRoot.+)
, the action to be taken is Rewrite: http://localhost:8080/{R:0}
.
For another application that uses https, the Rewrite rule is: https://localhost:8181/{R:0}
.
In order to route https requests, I have read somewhere that I need to share the same certificate between IIS and Java, because IIS encrypts / decrypts the requests / answers. Correct me if I am wrong.
Since I am still at a development stage, I decided to share a self-signed certificate. I have created it with SelfSSL7
and I have imported into java keystore
using keytool
:
selfSSL7 /Q /T /I "Default web site" /N cn=myDomain.com /X /F MyCertificate.pfx /W myPassword
keytool -importkeystore -srckeystore C:\myPath\MyCertificate.pfx -srcstoretype pkcs12 -srcalias my -deststoretype jks -deststorepass myPassword -destalias MyAlias
Question
Both certificates do their job: https://myDomain.com
and https://myDomain.com:8181
are up and running, but when trying to route, I get the error:
502 - Web server received an invalid response while acting as a gateway or proxy server.
There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server.
Looking at the certificates, however, there are differences in: Issued to, Issued by, validity, Signature Algorithm, key size. In particular, the algorithm for the one created by SelfSSL7 is sha1RSA (1024 Bits key), and the one created by keytool is sha256RSA (2048 Bits key).