1

As we know,we provide http service listenning at 80 port,https service listenning at 443 port. Why don't we provide two services on one port? What is the specific reason? And how does netty server supports both Http and Https protocols with a single port?

Cherokee
  • 143
  • 8

1 Answers1

1

You can do this but I think its a bad idea as both ports are well defined for either http or https. That said if you really want to do this you can detect if SSL is used or not based on the first 5 bytes of a message and then inject the SSL handler on the fly.

Netty itself includes OptionalSslHandler which does exactly this for you:

https://github.com/netty/netty/blob/netty-4.1.32.Final/handler/src/main/java/io/netty/handler/ssl/OptionalSslHandler.java

Norman Maurer
  • 23,104
  • 2
  • 33
  • 31