Method for limiting website access based on IP attribution and local module
By loading the IP attribution database on the server and intercepting HTTP requests from unintentional areas, the problem that existing technology cannot completely block IP access from unintentional areas is solved, and intelligent restriction of user access in specific areas is realized, providing information for foreign trade enterprises and Effective protection against hackers.
Patent Information
- Application Number
- CN202311149786.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-07
- Publication Date
- 2024-09-17
AI Technical Summary
Existing technology cannot completely block IP access from unintentional areas, and IP blacklists and WAF software have problems of slipping through the net and occupying resources when protecting against network attacks.
By loading the IP attribution database on the server, capturing the user's IP and request type, querying the access behavior configuration database, judging and intercepting HTTP requests from unintentional regions, intelligently restricting or allowing access to users in specific regions.
It realizes intelligently restricting or allowing access to users in specific regions, solves the problem of local user access for foreign trade companies, and provides specific region protection against hackers.
Smart Images

Figure CN118659889A
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of network security, and in particular relates to a method and a local module for limiting website access based on IP location. Background Art
[0002] Currently, foreign trade enterprises mainly use intelligent DNS resolution. DNS domain name resolution is a service that points the domain name to the website space IP, allowing people to easily access the website through the registered domain name. Intelligent DNS resolution will determine whether to return the real IP of the intended area site based on the user's source. However, the problem with this method is that users can force the domain name to be resolved to a specified IP in the hosts file of the operating system, and can still access the intended area site of the foreign trade enterprise normally. Therefore, this solution cannot completely block non-intended area IPs.
[0003] Currently, the industry generally adopts adding IP blacklists to the operating system firewall and cooperating with WAF software to protect against network attacks. However, IP blacklists cannot completely block foreign IPs, and adding too many IPs to the firewall will lead to problems such as slow network access and occupation of system resources. Although WAF software can protect against network attacks, it is inevitable that some will slip through the net. Summary of the invention
[0004] The purpose of the present invention is to overcome the problems of the prior art and disclose a method and a local module for limiting website access based on IP location. The present invention can intelligently limit or allow users in a specific area to access a local server.
[0005] On the one hand, the purpose of the present invention is achieved by the following technical solutions:
[0006] A method for limiting website access based on IP location, the method comprising the following steps:
[0007] Step 1: When starting a website on the server, first check whether the website in the same application pool has loaded the IP location library. If it has, reuse the existing hot data; otherwise, load it from the local file;
[0008] Step 2: Load the global access behavior configuration library and the site access behavior configuration library respectively; the global access behavior configuration library configures the default access behavior of each website, and the site access behavior configuration library configures personalized access behavior for specific websites;
[0009] Step 3: When a user initiates a request to access a website, the server local module captures the user's IP and request type;
[0010] Step 4: Use the visitor's IP address to query the IP location database to obtain the visitor's location information;
[0011] Step 5: Query the access behavior configuration library based on the visitor's region information and request type to determine whether to prohibit the current HTTP request;
[0012] Step 6: When the HTTP request is a prohibited access behavior, it is intercepted before the website code execution stage.
[0013] According to a preferred implementation, in step 2, the foreign trade entity configures the visitor IP in the local area to prohibit sending GET, POST, PUT, DELETE, HEAD, and OPTIONS requests to its server, while allowing the visitor IP in the foreign trade market to send GET, POST, PUT, DELETE, HEAD, and OPTIONS requests to its server.
[0014] According to a preferred implementation, in step 2, the hacker prevention subject configures the visitor IP in the prevention area to prohibit sending POST, PUT, DELETE, HEAD, and OPTIONS requests to its server, and only allows GET requests.
[0015] According to a preferred implementation, the request types in step three include: GET, POST, PUT, DELETE, HEAD, and OPTIONS.
[0016] According to a preferred implementation, in step 4, the IP location database stores the region information corresponding to each IP segment.
[0017] According to a preferred implementation, in step six, when interception is performed, a 403 error page indicating access is prohibited is returned simultaneously.
[0018] On the other hand, the present invention also discloses:
[0019] A local module of a web server, which implements the aforementioned method for limiting website access when called by the web server.
[0020] The aforementioned main scheme of the present invention and its further options can be freely combined to form multiple schemes, all of which are schemes that can be adopted and claimed for protection by the present invention. After understanding the scheme of the present invention, those skilled in the art can understand that there are multiple combinations based on the prior art and common knowledge, all of which are technical schemes to be protected by the present invention, and they are not exhaustively listed here.
[0021] Beneficial effects of the present invention: Through the method and local module for limiting website access based on IP location, it is possible to intelligently limit or allow users in a specific region to access a local server. Thus, the access problem of users in the local region of a foreign trade entity can be solved, or it can be used to prevent hackers in a specific region for entities with hacker protection needs. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 It is a flowchart of a method for limiting website access based on IP location according to an embodiment of the present invention. DETAILED DESCRIPTION
[0023] The following describes the embodiments of the present invention by specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied by other different specific embodiments, and the details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the following embodiments and the features in the embodiments can be combined with each other without conflict. It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.
[0024] Example 1
[0025] refer to Figure 1 As shown, this embodiment takes IIS as the preferred embodiment, but it does not mean that it is only suitable for IIS. This case is not limited to any specific form of Web server. These changes and modifications should be regarded as falling within the scope of protection of this case.
[0026] Figure 1 A method for limiting website access based on IP location is shown in FIG. 1 , and the method for limiting website access includes the following steps:
[0027] Step 1:
[0028] When starting a website on IIS, load the IP location library or reuse existing hot data.
[0029] Step 2:
[0030] Load the global access behavior configuration library and the site access behavior configuration library respectively, which are mainly used to configure different access behaviors (such as GET, POST, PUT, DELETE, etc.) for different locations. For example:
[0031] ① Foreign trade enterprises can configure visitor IPs from non-intended regions to prohibit them from sending GET, POST, PUT, DELETE, HEAD, and OPTIONS requests to the server, while allowing IPs from intended regions to send GET, POST, PUT, DELETE, HEAD, and OPTIONS requests to the server. This configuration can achieve the effect of shielding IPs from non-intended regions from accessing the overseas sites of foreign trade enterprises.
[0032] ② To prevent network attacks from hacker organizations in the intended region, you can configure the visitor IP in the intended region to prohibit sending POST, PUT, DELETE, HEAD, OPTIONS requests to the server, and only allow GET requests. This is because POST, PUT, DELETE, HEAD, OPTIONS, and other HTTP requests are mainly used to submit forms to the website, upload files, delete files, etc. GET requests are mainly used to browse web pages. This configuration can achieve the effect that the visitor IP in the intended region is only allowed to browse web pages and is prohibited from submitting data to the server.
[0033] The global access behavior configuration library can configure the default access behavior for all websites, and the site access behavior configuration library can configure personalized access behavior for a specific website.
[0034] Step 3:
[0035] Taking IIS (Internet Information Services, Microsoft Web Server) as an example, when a user initiates a request to access a website, the IIS native modules can capture the user's IP (i.e. visitor IP) and request type (such as GET / POST / PUT / DELETE, etc.).
[0036] IIS 7.0 and higher versions can extend the Web server function through a native module. This embodiment obtains the HTTP request message and the visitor IP through the function provided by the native module.
[0037] Step 4:
[0038] Use the visitor's IP to query the IP location database to obtain the visitor's region information. The IP location database stores the region information corresponding to the IP segment. The non-intended region can be accurate to the county level, and the intended region can be accurate to the city (state) level, but we only need to determine whether the region belongs to the non-intended region or the intended region.
[0039] Step 5:
[0040] According to the visitor's region information and request type (GET, POST, PUT, DELETE, HEAD, OPTIONS), query the access behavior configuration library to determine whether to prohibit the current HTTP request.
[0041] Step 6:
[0042] When the HTTP request is a prohibited access behavior, it is directly intercepted before the website code execution stage and a 403 error page indicating prohibited access is returned.
[0043] Example 2
[0044] The present invention also discloses a local module of a web server. When the local module is called by the web server, the method for limiting website access based on IP location described in Example 1 is implemented.
[0045] Through the method and local module for limiting website access based on IP location of the present invention, it is possible to intelligently limit or allow users in a specific region to access the local server. Thus, the access problem of users in the local region of foreign trade entities can be solved, or it can be used to prevent hackers in specific regions for entities with hacker protection needs.
[0046] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for limiting website access based on IP location, characterized in that: The method for limiting website access comprises the following steps: Step 1: When starting a website on the server, first check whether the website in the same application pool has loaded the IP location library. If it has, reuse the existing hot data; otherwise, load it from the local file; Step 2: Load the global access behavior configuration library and the site access behavior configuration library respectively; the global access behavior configuration library configures the default access behavior of each website, and the site access behavior configuration library configures personalized access behavior for specific websites; Step 3: When a user initiates a request to access a website, the web server local module captures the user's IP and request type; Step 4: Use the visitor's IP address to query the IP location database to obtain the visitor's location information; Step 5: Query the access behavior configuration library based on the visitor's region information and request type to determine whether to prohibit the current HTTP request; Step 6: When the HTTP request is a prohibited access behavior, it is intercepted before the website code execution stage.
2. The method for limiting website access based on IP location as claimed in claim 1, characterized in that: In step 2, the foreign trade entity configures the visitor IP in the local area to prohibit sending GET, POST, PUT, DELETE, HEAD, and OPTIONS requests to its server, while allowing the visitor IP in the foreign trade market to send GET, POST, PUT, DELETE, HEAD, and OPTIONS requests to its server.
3. The method for limiting website access based on IP location as claimed in claim 2, characterized in that: In step 2, the hacker prevention entity configures the visitor IP in the prevention area to prohibit sending POST, PUT, DELETE, HEAD, and OPTIONS requests to its server, and only allows GET requests.
4. The method for limiting website access based on IP location as claimed in claim 1, characterized in that: The request types in step 3 include: GET, POST, PUT, DELETE, HEAD, and OPTIONS.
5. The method for limiting website access based on IP location as claimed in claim 1, characterized in that: In step 4, the IP location database stores the region information corresponding to each IP segment.
6. The method for limiting website access based on IP location as claimed in claim 1, characterized in that: In step six, when intercepting, a 403 error page indicating access is prohibited is returned at the same time.
7. A local module of a web server, characterized in that: When the local module is called by the web server, the method according to any one of claims 1 to 6 is implemented.
