danode - a home made web server in d

9
DaNode - A home made web server in D Talk #dconf 2016 Berlin Herr Dr. Danny Arends Fachgebiet Züchtungsbiologie und molekulare Tierzüchtung Lebenswissenschaftliche Fakultät Humboldt-Universität zu Berlin

Upload: andrei-alexandrescu

Post on 19-Jan-2017

456 views

Category:

Software


0 download

TRANSCRIPT

Page 1: DaNode - A home made web server in D

DaNode - A home made web server in D

Talk #dconf 2016 Berlin Herr Dr. Danny Arends Fachgebiet Züchtungsbiologie und molekulare Tierzüchtung Lebenswissenschaftliche Fakultät Humboldt-Universität zu Berlin

Page 2: DaNode - A home made web server in D

∗ Simple & Small codebase ∗ No plugins, single executable

∗ Portable ? Windows / Linux / ARM ∗ Dump a script in a folder,

Generate HTML ∗ Any language as CGI ∗ Domain names?

∗ No java anymore ∗ Run my own homepage (php)

What I was looking for

Page 3: DaNode - A home made web server in D

∗ Install the brainfuck compiler ∗ Create a script echo "++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.-

-------.>+.>." > www/dannyarends.nl/hello.brainfuck

∗ Update the supported mime-types case ".brainfuck" : return CGI_FILE ~ "bfuck -n -C";

∗ Stop server, recompile and restart

As simple as

Page 4: DaNode - A home made web server in D

∗ Internet Information Services (Microsoft) ∗ Familiar web server, easy install ∗ No access to server source code ∗ Windows only

∗ Apache ∗ Full blown web server ∗ Complex setup, huge source code ∗ Different plugins change behavior

∗ I did not want to add plugins for every feature ∗ Too massive for what I wanted

Alternatives

Page 5: DaNode - A home made web server in D

∗ Vibe.d ∗ 0.7.4 - March 2012 ∗ Looked very promising (async I/O, Templates) ∗ Features offered by vibe.d were limited

∗ Too high level for what I wanted ∗ Templated language for HTML ∗ No PHP support

∗ Changes were still quite common

∗ Hindsight: vibe.d would have been the better choice

Alternatives

Page 6: DaNode - A home made web server in D

∗ Any programming language as CGI ∗ As simple as in the brainfuck example

∗ Service many (secure) domains with a single server ∗ SSL using Deimos and Server Name Indication (SNI)

∗ Per website configurations ∗ Request redirection (Canonical URLs) ∗ Directory browsing

∗ Streamed and/or buffered file downloads ∗ Minimal memory foot-print ∗ < 2000 lines of code

DaNode Features

Page 7: DaNode - A home made web server in D

∗ Useful for quick and dirty tasks ∗ Running several domains for 4 years ∗ DaNode does not follow HTML specifications

∗ SSL is probably not very secure ∗ CGI is probably not very secure

∗ Perhaps replace core parts by vibe.d ∗ No unit-tests yet, but travis-ci

∗ Aiming for full code coverage ∗ Find people interested

Why this talk

Page 8: DaNode - A home made web server in D

Humboldt-Universität zu Berlin dannyarends.nl @DannyArends github.com/DannyArends Any and all feedback, help, and/or pull requests are appreciated

Any questions ?

Page 9: DaNode - A home made web server in D

Install the current DMD compiler: https://dlang.org/download.html git clone https://github.com/DannyArends/DaNode.git cd DaNode rdmd --build-only -O -gc -release -w danode/server.d ./danode/server –p 8080 Open firefox: http://localhost:8080/

Install DaNode