bind to all addresses and drop privileges

This commit is contained in:
Johannes Loher 2018-11-27 20:31:20 +01:00
parent c1c8747136
commit 7147315b04
2 changed files with 6 additions and 2 deletions

View file

@ -2,6 +2,10 @@ FROM dlang2/dmd-ubuntu
WORKDIR /dlang/vibe-docker WORKDIR /dlang/vibe-docker
COPY . . COPY . .
RUN useradd --user-group --create-home --shell /bin/false app
RUN chown -R app:app /dlang/vibe-docker
USER app
RUN dub build -v RUN dub build -v
EXPOSE 8080 EXPOSE 8080

View file

@ -4,14 +4,14 @@ void main()
{ {
auto settings = new HTTPServerSettings; auto settings = new HTTPServerSettings;
settings.port = 8080; settings.port = 8080;
settings.bindAddresses = ["::1", "127.0.0.1"]; settings.bindAddresses = ["::", "0.0.0.0"];
listenHTTP(settings, &hello); listenHTTP(settings, &hello);
logInfo("Please open http://127.0.0.1:8080/ in your browser."); logInfo("Please open http://127.0.0.1:8080/ in your browser.");
runApplication(); runApplication();
} }
void hello(HTTPServerRequest req, HTTPServerResponse res) void hello(HTTPServerRequest, HTTPServerResponse res)
{ {
res.writeBody("Hello, World!"); res.writeBody("Hello, World!");
} }