Hi Ron.
There is a way, as shown below. Note though, that you rarely need it, as you already have to specify multiple <serviceProxy>s (and therefore, as shown in the example, probably already have multiple <groovy> interceptors) to distinguish between SSL ports and non-SSL ports.
<serviceProxy port="443">
<ssl>
<keystore location="../router/conf/membrane.jks" password="secret" keyPassword="secret" />
<truststore location="../router/conf/membrane.jks" password="secret" />
</ssl>
<groovy>
import com.predic8.membrane.core.rules.SSLableProxy
if ((exc.rule instanceof SSLableProxy) && ((SSLableProxy) exc.rule).getSslInboundParser() != null) {
println "this has SSL/TLS"
} else {
println "this has no SSL/TLS"
}
</groovy>
<target host="thomas-bayer.com" />
</serviceProxy>
<serviceProxy>
<groovy>
import com.predic8.membrane.core.rules.SSLableProxy
if ((exc.rule instanceof SSLableProxy) && ((SSLableProxy) exc.rule).getSslInboundParser() != null) {
println "this has SSL/TLS"
} else {
println "this has no SSL/TLS"
}
</groovy>
<rewriter><map from="/(.*)" to="https://localhost/$1" /></rewriter>
</serviceProxy>
Usually, the switch from non-SSL to SSL (or vice versa) is done as shown in the example ssl-client (or ssl-server, respectively).
However, as this does not cover all use cases, it can, of course, been done programmatically as well: 1) specifying no <ssl/> within the <target/>, 2) setting (or not setting) the SSL_CONTEXT property on the exchange and 3) changing the schema of the destination URL.
<router id="router">
<serviceProxy>
<groovy>
import com.predic8.membrane.core.transport.ssl.StaticSSLContext
import com.predic8.membrane.core.config.security.SSLParser
def router = spring.getBean("router")
exc.setProperty("SSL_CONTEXT", new StaticSSLContext(new SSLParser(), router.getResolverMap(), router.getBaseLocation()))
exc.getDestinations().clear();
exc.getDestinations().add("https://www.predic8.de");
</groovy>
<target host="www.predic8.de" />
</serviceProxy>
</router>
Best, Tobias