statiqdev / Statiq.Web

Statiq Web is a flexible static site generator written in .NET.
https://statiq.dev/web
Other
1.65k stars 236 forks source link

Consider adding random port number and custom host names support #641

Open avishnyakov opened 6 years ago

avishnyakov commented 6 years ago

It would be nice to have an ability to use custom host names along with http://localhost:port notation.

Currently, Wyam provides a custom port number which helps to stand up as many web sites as we need to. Works well but does not support multi-web-site scenario well. Imagine 3-5 web sites which need to be up at the same time. Every time we need to make sure a custom, unique port number is used, and then remember on which port which web site is. Too much work.

As an example of this case is "usual" dev/uat/prod scenario where we stand up the same version of the web site built with different content, theme and changes. Side by side view helps a lot.

It would be nice if we could assign a host name referring to a particular web site by it's alias, something like:

For example, we would be using current git branch as a part of the host name. Kinda blue/green deployment:

To support this, Wyam can also pick up a free port automatically, stand up web site, and then use hostname.

That would be really cool - no need to specify port, easy to standup whatever we want and how we want, and human friendly way to get to the web site.

daveaglick commented 6 years ago

The orchestration involved would be tricky. For one, Wyam can't just allocate a hostname and expect it to work - that requires some sort of DNS support on the part of the local host, like adding an entry in the hosts file.

Then, once the desired .local domain names point to the loopback IP (127.0.0.1), in order for Wyam to respond to those hostnames without requiring a port, every instance would have to listen on port 80 and the correct one would need to reply by examining the host header. Usually a single application process would bind to that port (I.e., when IIS serves multiple sites from port 80 using host headers, the single IIS process gets the request and then funnels it to the appropriate site). I'm pretty sure Kestrel can do that part of it, but we would have many different Wyam processes needing to respond to port 80 - not sure that's even possible.