1

I am running two http/2 servers on my ubuntu server. Both should be reachable over port 443.

App A:

Runs on port 8443 and should get requests for domain.com

App B:

Runs on port 8444 and should get requests for subdomain.domain.com

Is there a simple way to do this on Ubuntu?

Pravitha V
  • 3,308
  • 4
  • 33
  • 51
Pat
  • 75
  • 2
  • 6

1 Answers1

2

Yes this is possible.

You need to run a webserver or loadbalancer listening to port 443 and forwarding requests appropriately.

In Apache for example this would be handled as follows:

Listen 443

<VirtualHost *:443>
    # This first-listed virtual host is also the default for *:443
    ServerName domain.com
    DocumentRoot "/www/domain"
    ProxyPass / h2://127.0.0.1:8443/
    ProxyPassReverse h2://127.0.0.1:8443/
</VirtualHost>

<VirtualHost *:443>
    ServerName subdomain.domain.com
    DocumentRoot "/www/otherdomain"
    ProxyPass / h2://127.0.0.1:8444/
    ProxyPassReverse h2://127.0.0.1:8444/
</VirtualHost>

Now while Apache does support HTTP/2 in both the front end client connections and the back end ProxyPass requests (with mod_proxy_http2), some other webservers/loadbalancers don't (e.g. Nginx). To be honest most of the benefits for HTTP/2 are in the client to edge. So if you prefer to use Nginx for example, you could just have Nginx support HTTP/2, and the connection from Nginx to your back end apps be plain old HTTP/1.1. At least until HTTP/2 becomes more regularly supported. See here for more discussion on this: HTTP2 with node.js behind nginx proxy

Barry Pollard
  • 40,655
  • 7
  • 76
  • 92
  • After applying this configuration and adding a few things like the SSL Certificate and SSL Proxy Engine it works for a few requests. Then suddenly apache uses 1+ G Ram and stops answering requests like it's entering a deadlock. The app on 8444 currently only answers with plain text and doesn't cause a problem like that. – Pat Aug 28 '17 at 19:38
  • I would suggest switching to HTTP/1.1 for the backend (change the h2:// to http:// in above config) and see if that works. If so might be a bug in mod_proxy_http2. As mentioned the benefit of HTTP/2 to the back end is arguable anyway. – Barry Pollard Aug 28 '17 at 19:41
  • Update: After increasing the MaxRequestWorkers to 1000 it went to 12G Memory Usage – Pat Aug 28 '17 at 19:46
  • Update: same advice as before. Find out if it's because you are using the experimental mod_proxy_http2 (which I've not used to be honest) by trying it with mod_proxy_http instead (which I've used extensively and not seen this issue with). – Barry Pollard Aug 28 '17 at 20:09
  • Thank you for your help, I solved the problem differently now. Since your solution should work in most cases, I mark your answer as the right one. I solved it using the vhost library for nodejs. I exported the express apps from my applications and imported them into the app that handles the vhosts. – Pat Sep 09 '17 at 09:24