0

I want to have two servers hosted on the same computer with the same port. It would connect to the server corresponding to the domain that the client tries to connect to.

Example:
server1.net:80 -> port 81
server2.net:80 -> port 82

I want this to work with other protocols as well, not only http and https

Also one of them is an apache server and the other one is a node server

They would also have different SSL certificates

kess
  • 1,204
  • 8
  • 19
  • Sounds like you'd need to write a third server application that multiplexes the requests coming in on port 80 to whatever "backing" server application should handle them. Keep in mind that while you may retrieve the hostname from the HTTP header, you probably won't have access to the requested hostname for other protocols. Also, this question doesn't really belong on StackOverflow, but is probably more suited for a site like [Server Fault](https://serverfault.com/). – Janus Varmarken Aug 13 '18 at 20:02
  • My current soulution has the exact problem that you said it only works with http, but here(https://stackoverflow.com/questions/187655/are-https-headers-encrypted), a person said that "TCP and IP headers are never encrypted. (If they were, your packets would not be routable.)" so there must be a way of doing this. – kess Aug 13 '18 at 20:13
  • TCP/IP carry no information about hostname in their respective headers. The client resolves a hostname to an IP by performing a DNS request, and initiates the a TCP connection to the returned IP address. Therefore, you'll never see what hostname the client performs a request to at your server. You'd have to specify your own application layer protocol that could carry the hostname (i.e. you'd essentially be transmitting the hostname as part of the TCP payload). – Janus Varmarken Aug 13 '18 at 20:24
  • Well if that is the case, is there a way to make this work with https at least? Can I set it so it doesn't encript the http headers? – kess Aug 13 '18 at 20:28
  • Since HTTP is port 80 by default, and HTTPS port 443, and other protocols on other ports, I fail to understand the "work with other protocols as well, not only http and https". – Patrick Mevzek Aug 13 '18 at 21:07
  • "They would also have different SSL certificates" How is the thing running on port 443 (as is the default for HTTPS, not 80) will know which certificate to return in the TLS handshake for clients connecting with **separate protocols**? Do all clients use SNI? It is not very clear what you want to achieve... For the HTTP(S) world what you are describing is a standard reverse proxy. But when you mix "other protocols" (which ones?) then it is not clear at all anymore... – Patrick Mevzek Aug 13 '18 at 21:09
  • with the "same port" I mean if I have two http servers they are both on 80 if I have two https servers they are both on 443 if I have two ftp servers they are both on 21, not all services would be on one port – kess Aug 14 '18 at 07:26

0 Answers0