IXWebSocket icon indicating copy to clipboard operation
IXWebSocket copied to clipboard

Configurable "doc root" for IXHttpServer

Open fweiss opened this issue 2 years ago • 2 comments

Currently when using IXHttpServer, static files are served from ".". This means static files have to be put into the same directory the server runs in. I think it is better practice to have a separate directory, such as "www" for the static files.

I propose a change to IXHttpServer, so that the line std::string path("." + uri); can use a member variable instead of the ".". The simplest way is simply to add to the IXHttpServer class a new member variablestd::String docRoot;. It would have default initialization to ".". I think simply public access would do, but need to review any security/extensibility concerns.

I'll open a PR after a short review by a committer.

fweiss avatar Mar 02 '23 19:03 fweiss

Well, I've found a work around. Run the (IXWebsocket) server in the directory where the static files are located. However other web servers, such as nginx, apache2, express provide for setting a doc root.

fweiss avatar Mar 05 '23 17:03 fweiss

That's a good suggestion. If you want to make a PR I'd be happy to consider it.

bsergean avatar Mar 30 '23 04:03 bsergean