Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How Http Server API routing requests to web programs

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces how to request Http Server API routing to the web program, the content is very detailed, interested friends can refer to, hope to be helpful to you.

Introduction

Web programs in containers are usually bound to a listening port} in http://0.0.0.0:{ or a listening port in http://+:{ to ensure that web applications can be accessed using container IP.

As we show in the ASP.NET Core official image, the ASP.NET Core program listens for requests on port 80 in the container

UrlPrefix

This involves an unknown concept: UrlPrefix

UrlPrefix is the prefix part of the uniform resource locator URL: scheme://host:port/relativeURI

"https://www.adatum.com:80/vroot/""https://adatum.com:443/secure/database/""http://+:80/vroot/"

After the web program starts, according to the host element in the listening address UrlPrefix, different routing buckets are registered with the system component Http Server API, and the Http Server API routes the received requests to the appropriate web program.

The web program listens for the http://+:80 address in the container, and + is a strong wildcard, which means that the web program listens for requests on port 80 with any hostname in the container (lightweight virtual machine).

There are four forms of host elements in the listening address UrlPrefix:

Strong wildcard (+)

When the host element is a plus sign (+) and UrlPrefix matches all possible hostnames, the UrlPrefix belongs to the strong wildcard category.

Strong wildcards are useful in scenarios where the web program ignores how the request arrives or the site specified in the request host header, the host element of the web server listening address can be set to strong wildcard + explicit hostname

When the host element is a fully qualified domain name, the host element of the web server directly matches the host header of the incoming request, and an explicit host name is useful for multiple sites where Web sites deliver different content depending on the site to which the request is directed. Weak wildcards that bind IP

The host element is the IP address, and this type of UrlPrefix matches any IP address hostname weak wildcard (*) that does not match the above strong wildcard or explicit hostname

When an asterisk * appears as a host element, this type of UrlPrefix will match any hostname that has not yet matched the above strong wildcards, explicit or IP-bound weak wildcards, which can be used as the default catch-all or to specify a larger portion of the URL namespace without having to use many UrlPrefixes

Http Server API maintains a routing table that determines which application receives incoming requests. This routing table is built from the reservation database. When a new registration or reservation entry is generated, it will be put into the routing bucket associated with a specific host element.

Route bucket priority

When the UrlPrefix listened to by multiple web programs overlap, the Http Server API will match according to the registered 1Http Server API-> 4 route buckets, and the longest match in the relative URI portion of the UrlPrefix in the routing bucket (assuming that the host of the URL, the port and the scheme partially match) is the best match. When a match is found in the routing bucket, the routing algorithm stops searching and skips all lower priority buckets.

For example, the following registration key:

Registration entry: https://+:80/vroot/ is registered by app1

Registration entry: https://adatum.com:80/ is registered by app2

Registration entry: https://*:80/ is registered by app3

Incoming requests for https://adatum.com:80/vroot/subdir/file.htm/ are routed to app1

Incoming requests for https://adatum.com:80/default.htm/ are routed to app2

Incoming requests for https://otheradatum.com:80/file.htm/ are routed to app3

HTTP Sever API provides a mechanism for routing requests to web programs. The host element of the application listening address UrlPrefix determines the routing policy, where the + strong wildcard indicates how to ignore the request hostname and the way in which the request is ignored, which can be considered a gulp to receive requests that satisfy (scheme, port, relativeUrl). When the UrlPrefix listened to by multiple web programs overlap, the route bucket formed by Http Server API based on the host element has priority on how to request Http Server API routing to the web program to share here. I hope the above content can be helpful to everyone and learn more. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report