I have a C# app I’m trying to get running in a docker container
.NET 4.5.2 Framework
mono 6.12
Owin rest service
The container has the port published
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3716895823c5 mytestapp "mono /opt/mytestapp…" 31 minutes ago Up 31 minutes 0.0.0.0:23456->23456/tcp testapp
Accessing from inside the container works as expected
$ docker exec -it testapp /bin/bash
root@3716895823c5:/# curl -v http://127.0.0.1:23456/api/v1/sessions/1
* Expire in 0 ms for 6 (transfer 0x562e32e240f0)
* Trying 127.0.0.1...
* TCP_NODELAY set
* Expire in 200 ms for 4 (transfer 0x562e32e240f0)
* Connected to 127.0.0.1 (127.0.0.1) port 23456 (#0)
> GET /api/v1/sessions/1 HTTP/1.1
> Host: 127.0.0.1:23456
> User-Agent: curl/7.64.0
> Accept: */*
>
< HTTP/1.1 200 OK
...
<
* Closing connection 0
{"id":1, ....
However, when trying from the host I get a * Mark bundle as not supporting multiuse
error.
$ curl -v http://127.0.0.1:23456/api/v1/sessions/1
* Trying 127.0.0.1:23456...
* Connected to 127.0.0.1 (127.0.0.1) port 23456 (#0)
> GET /api/v1/sessions/1 HTTP/1.1
> Host: 127.0.0.1:23456
> User-Agent: curl/7.81.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 400 Bad Request
< Content-Type: text/html; charset=us-ascii
< Server: Mono-HTTPAPI/1.0
< Date: Mon, 26 Sep 2022 20:16:27 GMT
< Content-Length: 35
< Connection: close
<
* Closing connection 0
<h1>Bad Request (Invalid host)</h1>$
Since the app works correct when I run it on ubuntu + mono, I assume this is somehow docker related. Unfortunately, I have yet not been able to find any solution for this
2
Answers
The actual issue here is not the issue stated in the title, but instead
Bad Request (Invalid host)
This happens when running app in docker and accessing through exposed port. The issue turns out to be with Owin and how it is set up. With the help from a colleague and this link, we narrowed down the issue and found the solution. OWIN-WebAPI-Service.
Solution is to use
http://+:<port>
for listening for requests. From the above linkThe message "Mark bundle as not supporting multiuse" is not an error, but a benign informational message. It only means that curl is connected with HTTP/1.1 ; the real problem is HTTP/1.1 400 Bad Request, as @Jesper Kristiansen pointed out above.
Also see this answer
Adding some clarity because the "multiuse" message is a red herring. Hopefully my answer will save someone some time by not chasing this red herring.