Skip to content

Enable http/3 from docker containers #45021

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
mrgleba opened this issue Nov 11, 2022 · 14 comments
Closed
1 task done

Enable http/3 from docker containers #45021

mrgleba opened this issue Nov 11, 2022 · 14 comments
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. HTTP3 Status: Resolved

Comments

@mrgleba
Copy link

mrgleba commented Nov 11, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

Right now it's very hard to run aspnet core http/3 from within a docker container.

  • the default docker images are missing libmsquic
  • there is no easy way to specify a true external port for alt-svc header

Describe the solution you'd like

The docker image for aspnet core should include the current libmsquic

There should be a configuration option for an external port in the alt-svc header.

Additional context

No response

@Tratcher
Copy link
Member

Tratcher commented Nov 11, 2022

there is no easy way to specify a true external port for alt-svc header

You can provide your own alt-svc header like this:

app.Use((context, next) =>
{
    context.Response.Headers.AltSvc = "h3=\":443\"";
    return next(context);
});

the default docker images are missing libmsquic

Getting libmsquic into the images is a good idea. @ManickaP?

@Tratcher Tratcher added the HTTP3 label Nov 11, 2022
@mrgleba
Copy link
Author

mrgleba commented Nov 14, 2022

I've tried that but so far with no success.

As I understand the port supplied in the alt-svc is a UDP port? Is that correct?
Right now there is no way to specify the UDP port number - it has to be the same as TCP port for HTTPS HTTP/1.1 & HTTP/2 (it's taken from the IPEndPint.Port) ?
Using HTTP/3 in docker would now require 3 port redirections:

  • TCP 80 (HTTP)
  • TCP 443 (HTTPS)
  • UDP from alt-svc (QUIC/HTTP3)

Is there any way to find out if libmsquic was successfuly found? I'm trying to diagnose my problem and this seems to be the case despite the library being installed manually (in mcr.microsoft.com/dotnet/aspnet:7.0 image)

@Tratcher
Copy link
Member

As I understand the port supplied in the alt-svc is a UDP port? Is that correct?
Right now there is no way to specify the UDP port number - it has to be the same as TCP port for HTTPS HTTP/1.1 & HTTP/2 (it's taken from the IPEndPint.Port) ?

Correct.

Is there any way to find out if libmsquic was successfully found?

Try QuicListener.IsSupported

@adityamandaleeka adityamandaleeka added the Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. label Nov 14, 2022
@ghost
Copy link

ghost commented Nov 14, 2022

Hi @mrgleba. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@adityamandaleeka
Copy link
Member

Related: #37311

@mrgleba
Copy link
Author

mrgleba commented Nov 15, 2022

I've finally managed to run http3 from the container.
I needed to change the port inside the container from 8443 to 443 (as it didn't work on that port, even with manual alt-svc).
I needed to use setcap 'cap_net_bind_service=+ep' /usr/share/dotnet/dotnet inside the container for dotnet to be able to bind to lower ports (we don't use root inside the container).
I needed to opt-in to preview featuser in .csproj

Using QuicListener.IsSupported requires opting-in to preview features. Is http/3 still in preview in 7.0?

@ghost ghost added Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels Nov 15, 2022
@Tratcher
Copy link
Member

Using QuicListener.IsSupported requires opting-in to preview features. Is http/3 still in preview in 7.0?

HTTP/3 is not in preview, but the lower level QUIC APIs are.

@MychellSantos
Copy link

MychellSantos commented Nov 16, 2022

I've finally managed to run http3 from the container. I needed to change the port inside the container from 8443 to 443 (as it didn't work on that port, even with manual alt-svc). I needed to use setcap 'cap_net_bind_service=+ep' /usr/share/dotnet/dotnet inside the container for dotnet to be able to bind to lower ports (we don't use root inside the container). I needed to opt-in to preview featuser in .csproj

Using QuicListener.IsSupported requires opting-in to preview features. Is http/3 still in preview in 7.0?
I'm trying to run inside a container but the connection is closed.
How was it possible to execute?

was it possible to perform overwrite with a self-signed certificate?

context;
.net 7
libmsquic 2.*
certificate self-sigend
config:

{
  "Kestrel": {
    "Endpoints": {
      "Https": {
        "Url": "https://+:443",
        "Protocols": "Http3"
      }
    }
 }

@Tratcher
Copy link
Member

Browsers are very strict about self-signed certs and HTTP/3. See #41762

@MychellSantos
Copy link

I was in doubt if http3 needs a certificate inside the application in the container, because my certificates are in the proxy/nginx.
my application doesn't even know if it has a certificate or not.

@adityamandaleeka
Copy link
Member

Marking this as answered since the discussion seems to have moved to dotnet/runtime#41762

@adityamandaleeka adityamandaleeka added the ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. label Nov 16, 2022
@ghost ghost added the Status: Resolved label Nov 16, 2022
@adityamandaleeka adityamandaleeka removed Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. Status: Resolved labels Nov 16, 2022
@ManickaP
Copy link
Member

Getting libmsquic into the images is a good idea. @ManickaP?

We have an issue for that: dotnet/dotnet-docker#4385.

Our previous experience with adding dependencies into official docker images led to push back due to the increased size, so we need more people caring about this scenario before we attempt to do this. Please upvote the issue if it's important for you!

@ghost
Copy link

ghost commented Nov 23, 2022

This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.

See our Issue Management Policies for more information.

@ghost ghost closed this as completed Nov 23, 2022
@mattchidley
Copy link

Building on what @mrgleba has posted, I just want to confirm that this worked for me:

  • libmsquic needs to be set and held at 1.9*
  • the webserver running inside the container needs to be running on 443
  • the Dockerfile needs to expose both TCP and UDP for the ports (EXPOSE 443/udp 443/tcp)
  • the Docker run command needs to forward both TCP and UDP traffic to the exposed ports (publish --port 443:443/udp --port 443:443/tcp

These things did not work:

  • if the webserver is running on a different port than 443, and you set the alt-svc header to be 443, HTTP/3 connections can be established but the browser will not negotiate connections using the h3 protocol (I don't know why).
  • I did not need to setcap 'cap_net_bind_service=+ep' /usr/share/dotnet/dotnet in order to bind lower ports, but that could just be based on the privilege I'm running

@ghost ghost locked as resolved and limited conversation to collaborators Jan 5, 2023
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Jun 2, 2023
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. HTTP3 Status: Resolved
Projects
None yet
Development

No branches or pull requests

8 participants