virtkick / http-master

versatile front end http service with reverse proxy
MIT License
139 stars 17 forks source link

http/2 #124

Closed zevero closed 7 years ago

zevero commented 7 years ago

I love http-master, which allows centralized and easy routing. Automatic free SSL option, frees all my apps from having to deal with https. Now after so much delight, I tried to get http/2 working with spdy or http2 npm modules - but no luck.

Is there a known way how to do that? Could there be such a thing like an http2-master?

Rush commented 7 years ago

Hi @zevero, thanks for your kind words regarding http-master. Try setting spdy: true in your ssl config block. Let me know if it worked. To be honest spdy/http2 benchmarks in Node are not extremely exciting. Maybe once native HTTP2 lands in Node.JS it will get better.

zevero commented 7 years ago

Hi Mr. @Rush (I was just reading Mr. Mens Mr. Rush to my kids!!!) thank you for your fast response!

I don't know how this works, but it is just spectacular or magic to say the least! I don't need to change my apps in any way. Just adding spdy: true did the trick for all of them. (I first tried to somehow include spdy npm module on my test-site, but in the end I saw that it was not needed and all my other apps are faster now !!)

???Why is this not documented???

Benchmarks are not exiting??? What are you saying! -> A page with 40 requests (mostly js) now loads in 0,5s instead of 3s!!! -> A page with 400 requests (mainly thumbnails) now loads in 4-6s (was +18s)!!

This is a tremendous improvement at the cost of only including ONE property in http-master.conf !!!

Thank you! And thank you again! And again!

In case somebody is looking into this. Down below is my test http-master.conf serving the page as normal http and http/2. Turning off http and redirecting it to https / http2 is done by changing the port number in line 5 simply to 'https://test.mysite.org'

So simple with letsencrypt: true So fast with spdy: true

(And I spent days in finding complicated solutions, which did not work.)

watchConfig: true
ports: {
  80: {
    router: {
      'test.mysite.org': 6080,
      '*': 8080
    }
  },
  443: {
    router: {
      'test.mysite.org': 6080,
   },
   ssl: {
      letsencrypt: true,
      spdy: true
    }
  }
}
middleware: ["log -> /var/log/http-master/access.log"]
modules: {
  appLog: "/var/log/http-master/app.log",
  letsencrypt: {
    configDir: '/etc/letsencrypt', # needs to be writable
    email: 'my.email@gmail.com',
    agreeTos: true
  }
}

Next I will try adding bringMeSomeChocolate: true and see what http-master is bringing me ... :-)

Rush commented 7 years ago

I am very glad it works well for you. Just note that as spdy is implemented in javascript (it's not native to Node.JS) it will handle less total amount of requests per second. I think you're experiencing quicker load times mainly due to protocol being much better but it still takes its toll on the CPU.

???Why is this not documented???

I guess mainly due to being kind of experimental. But maybe I should reconsider. btw. pull requests are welcome :)

zevero commented 7 years ago

Pull request for documentation https://github.com/virtkick/http-master/pull/125