Open matthewp opened 9 years ago
My goal with serv
was to create a quick and dirty way to expose a directory over http for local development. Virtual hosts feels more like a production web server feature, but I'm willing to explore it.
Before you take the time to implement something, what is your proposed user interaction model?
I share your goal, this is something that I want to use in development. The thing I like about serv is that it's lightweight in comparison to Apache/Nginx, so I have no desire to add production server features. I would propose a small configuration file that can be used as an alternative to the cli options. Perhaps something like:
{
"servers": [
{ "name": "local.work", "port": 8080 },
{ "name": "local.play", "port": 8081, "path": "/home/matthew/playground", "public": true }
]
}
The options would match the cli options but with the addition of name
which is the serverName. In case where 2 servers share a common port we have a single server that separates traffic based on name
.
serv still works the way it current does by default, this mode is only activated manually, something like:
serv --config serv.json
Forgive me, what does this have to do with virtual hosts? To me a virtual host is when you distinguish the content that is served based on the HTTP Host header.
Yes, that is what name
is in this example. In Apache it's ServerName
, in Nginx it's server_name
. I was trying to keep it short but serverName
might make it clearer. Does that answer your question?
Would you be open to a feature equivalent to Apache virtual hosts or Nginx server blocks? I'd like to run a single instance of
serv
that serves multiple directories and differentiate based on host names. If this is something you would consider I'd be happy to implement it.