Domain name deployment method and system
By deploying multiple micro applications under the same domain name and utilizing Nginx proxy rules and caching policies, the problems of traditional application architecture deployment complexity and cross-domain request restrictions are solved, and efficient micro application collaborative work and user experience improvement are achieved.
Patent Information
- Application Number
- CN202411033730.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-30
- Publication Date
- 2024-12-24
AI Technical Summary
Traditional application architectures need to operate the entire application during deployment and update, resulting in resource dispersion, complex management and maintenance, and cross-domain request restrictions increase front-end development complexity.
Deploy multiple micro-applications under the same domain name. Each micro-application sets its own access path and maps the access path to the backend service address through the Nginx server configuration proxy rules, and configures static resources and dynamic content caching policies in Nginx.
It realizes efficient deployment and collaborative work of multiple micro applications under the same domain name, reducing system maintenance complexity and improving user experience and development efficiency.
Smart Images

Figure CN119182753A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of domain name deployment, and in particular, relates to a domain name deployment method and system. Background Art
[0002] Micro front-end architecture is an architectural approach that splits the front-end application into smaller, more independent parts. Each micro application can be developed, deployed, and run independently, and a complete user interface can be built by combining these micro applications.
[0003] In traditional application architecture, each application is usually deployed under a different domain name or subdomain, which leads to scattered resources and difficulty in management and maintenance. At the same time, cross-domain request restrictions increase the complexity of front-end development. When deploying and updating traditional monolithic applications or simple micro-application architectures, the entire application often needs to be operated, which increases deployment time and risk. Summary of the invention
[0004] In view of this, the present application aims to propose a domain name deployment method and system to solve at least one of the above problems.
[0005] To achieve the above purpose, the technical solution of this application is implemented as follows:
[0006] In a first aspect, the present application provides a domain name deployment method, comprising:
[0007] Deploy multiple micro-applications under the same domain name, set up their own access paths for each micro-application, and generate corresponding static resource files;
[0008] By configuring proxy rules in the Nginx server, the access paths of different micro-applications are mapped to their respective backend service addresses;
[0009] A cache strategy is configured in the Nginx proxy, wherein the cache strategy includes static resource cache and dynamic content cache.
[0010] In a second aspect, based on the same inventive concept, the present application also provides a domain name deployment system, including:
[0011] The micro-application deployment module is configured to deploy multiple micro-applications under the same domain name. Each micro-application sets its own access path and generates corresponding static resource files.
[0012] The proxy module is configured to map the access paths of different micro-applications to their respective backend service addresses by configuring proxy rules in the Nginx server;
[0013] The cache module is configured to configure a cache strategy in the Nginx proxy, wherein the cache strategy includes static resource cache and dynamic content cache.
[0014] In a third aspect, based on the same inventive concept, the present application also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method described in the first aspect is implemented.
[0015] In a fourth aspect, based on the same inventive concept, the present application also provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the method described in the first aspect.
[0016] Compared with the prior art, the domain name deployment method and system described in this application have the following beneficial effects:
[0017] A domain name deployment method and system described in this application realizes efficient deployment and collaborative work of multiple micro-applications under the same domain name through the Nginx proxy gateway, bringing new possibilities for front-end development and deployment, and providing better user experience and development efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0019] Figure 1 A flow chart of a domain name deployment method described in an embodiment of the present application;
[0020] Figure 2 A schematic diagram of a domain name deployment system architecture described in an embodiment of the present application;
[0021] Figure 3 A schematic diagram of the structure of a domain name deployment system described in an embodiment of the present application;
[0022] Figure 4 This is a schematic diagram of the hardware structure of the electronic device described in the embodiment of the present application. DETAILED DESCRIPTION
[0023] In order to make the objectives, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in combination with specific embodiments and with reference to the accompanying drawings.
[0024] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the embodiments of the present application should be the usual meanings understood by people with ordinary skills in the field to which the present application belongs. The "first", "second" and similar words used in the embodiments of the present application do not represent any order, quantity or importance, but are only used to distinguish different components. "Including" or "comprising" and similar words mean that the elements or objects appearing in front of the word cover the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0025] The embodiments of the present application are described in detail below with reference to the accompanying drawings.
[0026] See also Figure 1 As shown, this embodiment provides a domain name deployment method, including:
[0027] Step S101: deploy multiple micro-applications under the same domain name, each micro-application sets its own access path and generates corresponding static resource files.
[0028] Specifically, in this embodiment, each micro-application is developed using a front-end framework (e.g., React, Vue.js, Angular, etc.) or a back-end framework (e.g., Node.js, Django, Flask, etc.), ensuring that each micro-application is independent and has its own business logic, data, and user interface. The application of the micro-front-end architecture allows the front-end application to be split and developed independently in a more fine-grained manner, and different teams can be responsible for their own micro-application development. This divide-and-conquer approach improves development efficiency and the convenience of code maintenance.
[0029] When building micro-applications, configure Webpack or other build tools to set the publicPath of each micro-application. The publicPath is the path of the build output directory, which determines the access path of the static resource files.
[0030] Deploy the static resource files (HTML, CSS, JavaScript, etc.) built by each micro-application to the server, copy the built files to a specific directory on the server, and ensure that Nginx or Apache on the server is configured correctly so that different virtual hosts or locations can be set for each micro-application.
[0031] Select the front-end gateway tool to configure the gateway, configure the gateway to support multiple micro-applications, including setting routing rules, load balancing, etc., deploy the build results of each micro-application to the server, and configure the server's Web server (such as Nginx) to proxy to the correct micro-application deployment directory.
[0032] The purpose of this step is to unify the entrance. After configuring the gateway, all micro-applications can be accessed through the same domain name. In this way, users only need to remember one domain name to access different applications without frequently switching domain names or ports, which improves the user experience.
[0033] Step S102: By configuring proxy rules in the Nginx server, the access paths of different micro-applications are mapped to their respective backend service addresses.
[0034] Specifically, in this embodiment, Nginx is a high-performance open source reverse proxy server that can proxy client requests to different backend servers. By configuring the Nginx proxy, the access paths of multiple micro-applications can be mapped to different backend service addresses, thereby achieving the goal of deploying multiple micro-applications under the same domain name.
[0035] By configuring proxy rules in the Nginx server, you can achieve access path mapping for multiple micro-applications. In this way, when users access different paths under the same domain name, the Nginx proxy will forward the request to the corresponding micro-application instance according to the path, which can achieve seamless integration of multiple micro-applications and simplify the user's access process to multiple services.
[0036] Furthermore, define a proxy rule for each micro-application in the Nginx configuration file, specifying to which backend service address the request should be forwarded when the user requests a specific path, and ensure that the server_name directive in the Nginx server configuration can match the domain name entered by the user. After the configuration is complete, use the nginx-s reload command to reload the Nginx configuration to make the new proxy rule effective.
[0037] To implement Nginx proxy to define proxy rules for each micro-application, you first need to create an upstream block in the Nginx configuration file and specify a set of backend servers for each micro-application; then, match the specific path in the location block and use the proxy_pass instruction to proxy the request to the corresponding backend service address. For example, for two micro-applications, define them as upstream blocks microservice1 and microservice2 respectively, and use / microservice1 / and / microservice2 / as path matching conditions in the location block. In this way, when the user request reaches the Nginx proxy, Nginx will route it to the corresponding micro-application according to the requested path. Make sure to configure Nginx correctly and reload or restart Nginx for the configuration to take effect.
[0038] This step can make the deployment and operation of different micro-applications more flexible and centralized through the Nginx proxy gateway. When updating, expanding or maintaining micro-applications, you only need to adjust the backend services without changing the front-end access method, which reduces the complexity of system maintenance.
[0039] Step S103: configure a cache strategy in the Nginx proxy, wherein the cache strategy includes static resource cache and dynamic content cache.
[0040] Specifically, in this embodiment, after configuring the gateway, a cache strategy is applied in the Nginx proxy to improve performance and user experience. Static resources, page content, and API data can be cached, reducing delays in resource requests and data acquisition.
[0041] Furthermore, for the caching of static resources: static resources usually do not change frequently, so they can be cached for a long time in the user's local browser or CDN. For the caching of static resources, a longer cache time can be set, such as using the Expires or Cache-Control header to set the resource cache time to one month. In this way, when the user visits the website, the browser can directly use the cached version without requesting it from the server.
[0042] To ensure that users always get the latest version of static resources, you can add a version number to the resource file name, or change the file fingerprint when the file content changes. When the resource is updated, just change the version number, the browser will recognize that the file has changed and request the latest version.
[0043] For caching page content, page caching can store the complete page HTML based on the URL requested by the user. Page caching can significantly improve the loading speed of the website, especially for static pages or dynamic pages that do not change frequently. In order to implement page caching, you can check the HTTP header information of the user's request to determine whether the page has been cached and has not changed. If the page has not changed, the server can return a 304 Not Modified status code to tell the browser to use the cached version.
[0044] For the caching of API interfaces, the caching of API interfaces can reduce the load on the backend server and speed up the response. This embodiment controls the caching behavior by setting the cache header of the API response, such as Cache-Control: public, max-age = 3600. For dynamically generated API responses, the caching logic is implemented on the API server, such as using a cache server such as Redis or Memcached to store intermediate results.
[0045] When setting up API interface cache, you need to consider the validity period of cached data. For API data that may change, you can use the negotiated cache strategy, that is, first check whether the local cache is expired, and if it is expired or not cached, then request the latest data from the server. For API data that does not change, use a strong cache strategy, that is, when the cache is not expired, the browser can directly use the cached version without requesting it from the server.
[0046] This method effectively reduces the delay of resource requests and data acquisition by introducing caching strategies, improves the performance of front-end applications, and strategies such as static resource caching, page caching, and API caching effectively reduce the load on the back-end server and accelerate the acquisition and display of user data.
[0047] The method described in this embodiment realizes the efficient deployment and collaborative work of multiple micro-applications under the same domain name through the Nginx proxy gateway, which brings new possibilities for front-end development and deployment and provides better user experience and development efficiency.
[0048] like Figure 2 As shown in the figure, the difference before and after configuring the gateway is mainly reflected in the system architecture and request processing flow. Before configuring the gateway, multiple micro-applications may be scattered under different domain names or ports, and each micro-application needs to be accessed independently, which increases the complexity of front-end development and maintenance. After configuring the gateway, multiple micro-applications can be accessed through different paths under the same domain name, which improves the flexibility, performance and user experience of the system.
[0049] It should be noted that the above describes some embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the above embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0050] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the embodiment of the present application also provides a domain name deployment system.
[0051] like Figure 3 As shown, the domain name deployment system includes:
[0052] The micro-application deployment module 11 is configured to deploy multiple micro-applications under the same domain name, each micro-application sets its own access path and generates corresponding static resource files;
[0053] The proxy module 12 is configured to map the access paths of different micro-applications to their respective backend service addresses by configuring proxy rules in the Nginx server;
[0054] The cache module 13 is configured to configure a cache strategy in the Nginx proxy, wherein the cache strategy includes static resource cache and dynamic content cache.
[0055] For the convenience of description, the above system is described by dividing the functions into various modules. Of course, when implementing the embodiments of the present application, the functions of each module can be implemented in the same or multiple software and / or hardware.
[0056] The system of the above embodiment is used to implement the corresponding method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be repeated here.
[0057] Based on the same inventive concept, corresponding to any of the above-mentioned embodiments and methods, an embodiment of the present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method described in any of the above embodiments is implemented.
[0058] Figure 4A more specific schematic diagram of the hardware structure of an electronic device provided in this embodiment is shown, and the device may include: a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050. The processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040 are connected to each other through the bus 1050 in the device.
[0059] The processor 1010 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.
[0060] The memory 1020 may be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 1020 may store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program codes are stored in the memory 1020 and are called and executed by the processor 1010.
[0061] The input / output interface 1030 is used to connect the input / output module to realize information input and output. The input / output module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.
[0062] The communication interface 1040 is used to connect a communication module (not shown) to realize communication interaction between the device and other devices. The communication module can realize communication through a wired mode (such as USB, network cable, etc.) or a wireless mode (such as mobile network, WIFI, Bluetooth, etc.).
[0063] The bus 1050 includes a path that transmits information between the various components of the device (eg, the processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040).
[0064] It should be noted that, although the above device only shows the processor 1010, the memory 1020, the input / output interface 1030, the communication interface 1040 and the bus 1050, in the specific implementation process, the device may also include other components necessary for normal operation. In addition, it can be understood by those skilled in the art that the above device may also only include the components necessary for implementing the embodiments of the present specification, and does not necessarily include all the components shown in the figure.
[0065] The electronic device of the above embodiment is used to implement the corresponding method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here.
[0066] Based on the same inventive concept, corresponding to any of the above-mentioned embodiments, the present application also provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the method described in any of the above embodiments.
[0067] The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device.
[0068] The computer instructions stored in the storage medium of the above embodiments are used to enable the computer to execute the method described in any of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.
[0069] Those skilled in the art should understand that the discussion of any of the above embodiments is merely illustrative and is not intended to imply that the scope of the present application (including the claims) is limited to these examples. In line with the concept of the present application, the technical features in the above embodiments or different embodiments may be combined, the steps may be implemented in any order, and there are many other variations of the different aspects of the embodiments of the present application as described above, which are not provided in detail for the sake of simplicity.
[0070] In addition, to simplify the description and discussion, and in order not to make the embodiments of the present application difficult to understand, the known power supply / ground connection with the integrated circuit (IC) chip and other components may or may not be shown in the provided drawings. In addition, the device can be shown in the form of a block diagram to avoid making the embodiments of the present application difficult to understand, and this also takes into account the fact that the details of the implementation of these block diagram devices are highly dependent on the platform to be implemented in the embodiments of the present application (that is, these details should be fully within the scope of understanding of those skilled in the art). In the case of elaborating specific details (e.g., circuits) to describe exemplary embodiments of the present application, it is obvious to those skilled in the art that the embodiments of the present application can be implemented without these specific details or when these specific details are changed. Therefore, these descriptions should be considered to be illustrative rather than restrictive.
[0071] Although the present application has been described in conjunction with specific embodiments of the present application, many replacements, modifications and variations of these embodiments will be apparent to those skilled in the art from the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may use the embodiments discussed.
[0072] The embodiments of the present application are intended to cover all such substitutions, modifications and variations that fall within the broad scope of the appended claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiments of the present application should be included in the scope of protection of the present application.
Claims
1. A domain name deployment method, characterized in that: include: Deploy multiple micro-applications under the same domain name, set up their own access paths for each micro-application, and generate corresponding static resource files; By configuring proxy rules in the Nginx server, the access paths of different micro-applications are mapped to their respective backend service addresses; A cache strategy is configured in the Nginx proxy, wherein the cache strategy includes static resource cache and dynamic content cache.
2. The method according to claim 1, characterized in that: Deploy multiple micro-applications under the same domain name, each micro-application sets its own access path, and generates corresponding static resource files, including: Build multiple micro-applications through the build tool, and set the corresponding access path for each micro-application to generate a result directory containing static resource files; Using a front-end gateway tool to configure a gateway, the configured gateway supports multiple micro applications; Deploy the build results of each micro-application to the server.
3. The method according to claim 1, characterized in that By configuring proxy rules in the Nginx server, the access paths of different micro-applications are mapped to their respective backend service addresses, including: A proxy rule is defined for each micro-application in the Nginx configuration file, specifying that when a user requests to access different paths under the same domain name, the request is proxied and load balanced so that the request is forwarded to the corresponding backend service address.
4. The method according to claim 3, characterized in that: Create an upstream block in the Nginx configuration file, specify a set of backend servers for each micro-app, match a specific path in the location block, and use the proxy_pass directive to proxy the request to the corresponding backend service address; When a user request reaches the Nginx proxy, Nginx checks the path of the request and routes it to the microapplication defined by the matching location block.
5. The method according to claim 1, characterized in that The caching strategy is configured in the Nginx proxy, wherein the caching strategy includes static resource caching and dynamic content caching, including: For static resource caching, set the cache time and add the version number to the static resource file name or change the file fingerprint when the static resource file content changes to trigger a refresh. The dynamic content includes at least page content and API interface. For page content caching, the entire HTML page or part of the page is stored in the cache, and the HTTP header information of the user request is checked to determine whether the page has been cached and has not changed; for API interface caching, the caching behavior is controlled by setting the cache header of the API response to cache the corresponding data of the API.
6. A domain name deployment system, characterized in that: include: The micro-application deployment module is configured to deploy multiple micro-applications under the same domain name. Each micro-application sets its own access path and generates corresponding static resource files. The proxy module is configured to map the access paths of different micro-applications to their respective backend service addresses by configuring proxy rules in the Nginx server; The cache module is configured to configure a cache strategy in the Nginx proxy, wherein the cache strategy includes static resource cache and dynamic content cache.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 5 is implemented.
8. A non-transitory computer-readable storage medium, characterized in that: in, The non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to cause a computer to execute the method according to any one of claims 1 to 5.
