-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Allow specifying host and port or port in ASPNETCORE_URLS #43135
Comments
That looks good. Thanks for writing it up. I think this proposal is a big improvement on approachability. There is still the question on what we should do in our Dockerfiles. I'd like to move away from a privileged port as the default. As a result, we could go with: ENV ASPNETCORE_URLS=5000 Your question on Here's what we should probably include in our # Directs Kestrel to listen on port 5000 on all addresses
ENV ASPNETCORE_URLS=5000
# To also enable HTTPS on port 5001, copy the following example to your app Dockerfile
# ENV ASPNETCORE_URLS=5000;https://+:5001
# To use privileged ports, copy the following example to your app Dockerfile
# ENV ASPNETCORE_URLS=http://+:80;https://+:443 |
Pros:
Concerns:
|
But not for basic dev. Most devs likely use raw HTTP on their desktops.
Ya. Agreed. That also popped for me. Our guidance could be to use symmetry (including in our Dockerfiles) when specifying both HTTP/HTTPS. And the raw form is solely for raw HTTP. If we feel that folks are moving to HTTPS only, then we could offer: |
More like: |
I don't think this is a big problem. HTTPs is already asymmetric since you need to provide a certificate elsewhere.
Very slowly. We'll have jumped the shark when you see things like golang and node start defaulting to https. Nobody else does.
Many apps run behind proxies that terminate TLS.
That sounds fine to me as well. |
I added an open question about defaulting to :: or 0.0.0.0 (ipv6 or ipv4 addresses). |
I don't know. It's quite a tradeoff.
Ideally, we push people to unix domain sockets for the latter so that secure concerns for intra-machine scenarios are resolved. |
That makes me think we should be using different fields for different formats: |
Kestrel binds to aspnetcore/src/Servers/Kestrel/Core/src/AnyIPListenOptions.cs Lines 13 to 34 in 2f29a5e
Notice how much simpler this is compared the localhost case. aspnetcore/src/Servers/Kestrel/Core/src/LocalhostListenOptions.cs Lines 12 to 82 in 2f29a5e
|
I think I agree with this. Would we ignore Kestrel ignores |
@Tratcher was proposing that |
@Tratcher should we also have a simplified API for binding directly to a port? |
Where, Hosting? Kestrel already has one. The target customer is config/clusters, not code. |
The
That's not true, my original issue has both. If you look at other platforms, they are APIs that allow specifying a port (look at the original issue and the golang sample). |
Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
Today ASP.NET Core allows specifying the scheme (http/https), host and port via a URL like syntax in ASPNETCORE_URLS and via the
IServerAddressesFeature
. This issue suggests we expand that the syntax supported to make it a bit more intuitive as this is a common production and container scenario. We want to make it more intuitive to specify the host and port or just the port to use for ASP.NET CORE applications. We can also take the opportunity to revisit what this new syntax would mean with respect to what the defaults are when pieces are unspecified.Note: * and + are hold overs from HTTP.sys that we support on Kestrel as well but it's not obvious to most users (in fact + and * mean different things with HTTP.sys but not with Kestrel). I'm not sure if 0.0.0.0 work with HTTP.sys.
Describe the solution you'd like
When specifying the URL, we should support the following syntax:
{host}:{port}
- Scheme = http, The host and port are specified:{port}
or{port}
= Scheme = http, host = bind to all addresses (the equivalent of + or * today), port specified.e.g.
via code
Open questions:
IServerAddressesFeature.Addresses
? These should return the processed urls.Urls
toAddresses
onWebApplicationBuilder
? No.WebApplicatiion.Run
? Yes we can consider it as its much less of a breaking change.Golang supports this syntax with their
Listen
API https://pkg.go.dev/net#Listen (the address portion).nodejs defaults to listening on all addresses when the host is omitted.
Additional context
See dotnet/dotnet-docker#3968 for some background on this but it's been discussed in the past.
cc @richlander
The text was updated successfully, but these errors were encountered: