Configuring Independent Address Access for Files
In most browsers, the maximum number of concurrent requests to the same address is limited to 6. Therefore, if a sheet view contains a large number of image files, the user may cause a queue of browser requests when clicking into such a view. In this case, if the user switches to another page when the browser request is not fully loaded, the browsing speed may be slowed down or the browser may even freeze.
To address the above phenomenon, you first need to ensure that the file service instance resources and network bandwidth are sufficient. Secondly, you can refer to this document to configure an independent address for file requests to prevent file requests from blocking other interface requests.
Stand-alone environment
If the independent file storage address uses the default 80/443 port of http/https, you do not need to specify the default 80/443 port in the address when configuring the relevant environment variables.
System single access address
Here, the current system access address is http://example.domain.com and the new file independent address http://file.domain.com is taken as an example.
Configuration steps
-
Modify the microservice
docker-compose.yamlconfiguration fileversion: '3'services:core:image: registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-core:7.4.2environment: &app-environmentENV_ADDRESS_MAIN: "http://example.domain.com"ENV_APP_VERSION: "7.4.2"ENV_API_TOKEN: "******"ENV_FILE_DOMAIN: "http://file.domain.com" #Add a new variable to specify the independent address of the fileENV_FILE_ADDRESS_MAIN: "http://file.domain.com" #Add a new variable to specify the independent address of the fileENV_HAP_INTRANET_FILE_ENDPOINT: "core:8880/file" #New variable, fixed valueports:- 8880:8880volumes:- ./volume/data/:/data/- ../data:/data/mingdao/datasc:image: registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-sc:3.2.0environment:<<: *app-environmentvolumes:- ./volume/data/:/data/ports:- 9000:9000 #Added port mapping to map port 9000 in the container to the hostcommand:image: registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-command:node1018-python36doc:image: registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-doc:2.0.0
Added variable configuration instructions:
ENV_FILE_DOMAIN: The file storage service specifies an independent file addressENV_FILE_ADDRESS_MAIN: Microservice specifies an independent file addressENV_HAP_INTRANET_FILE_ENDPOINTfixed value "core:8880/file"- If the independent file address uses the default 80/443 port of http/https, you do not need to specify the default 80/443 port when configuring the above two variables.
Added port mapping instructions:
- 9000:9000maps the file service port in the container to the host to allow the nginx agent to access the file service in the next step
doc service variable modification instructions:
ENV_FILE_INNER_URI, the default variable value is changed tosc:9000
-
Restart the microservice
-
Add nginx cross-domain proxy configuration for file independent address. For the proxy configuration file, please refer to the configuration below.
upstream file {server 192.168.0.10:9000; #Specify the IP of the backend microservice and map it to the file storage port on the microservice host}server {listen 80;server_name file.domain.com; #Specify independent file addressaccess_log /data/logs/weblogs/file.domain.com.log main; #Log path, customizableerror_log /data/logs/weblogs/file.domain.com.error.log; #Log path, customizablelocation / {if ($request_method = OPTIONS) {return 204 "";}proxy_set_header HOST $http_host;proxy_pass http://file;proxy_hide_header Access-Control-Allow-Origin;add_header Access-Control-Allow-Headers authorization,content-type;add_header Access-Control-Allow-Origin "http://example.domain.com"; #Specify HDP system access address}} -
After the proxy configuration is completed, clear the browser cache. You can then use the browser developer tools to see whether file-related requests have gone to independent addresses in Network.
System multiple access addresses
In a system with multiple access addresses, when configuring independent addresses for file services, you need to configure an independent file address for each system access address.
Here we take the current system main access address example-external.domain.com and extended address example-internal.domain.com as an example.
Add two independent file access addresses file-external.domain.com and file-internal.domain.com to the two access addresses.
The corresponding relationship between system access address and file independent access address is as follows:
| Address type | Primary address | Extended address |
|---|---|---|
| System access address | example-external.domain.com | example-internal.domain.com |
| File independent address | file-external.domain.com | file-internal.domain.com |
Configuration steps
-
Modify the microservice
docker-compose.yamlfile, add relevant configurations and restart the microserviceversion: '3'services:core:image: registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-core:7.4.2environment:ENV_ADDRESS_MAIN: "http://example-external.domain.com"ENV_APP_VERSION: "7.4.2"ENV_FILE_DOMAIN: "http://file-external.domain.com,http://file-internal.domain.com" #Add new variables to specify multiple independent addresses of filesENV_FILE_ADDRESS_MAIN: "http://file-external.domain.com" #Add a new variable to specify the main independent address of the fileENV_HAP_INTRANET_FILE_ENDPOINT: "core:8880/file" #New variable, fixed valueports:- 8880:8880- 18880:18880volumes:- ./volume/data/:/data/- ../data:/data/mingdao/datasc:image: registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-sc:3.2.0environment:<<: *app-environmentvolumes:- ./volume/data/:/data/ports:- 9000:9000 #Added port mapping to map port 9000 in the container to the hostcommand:image: registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-command:node1018-python36doc:image: registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-doc:2.0.0
Added variable configuration instructions:
ENV_FILE_DOMAINspecifies multiple independent file access addresses for the file storage serviceENV_FILE_ADDRESS_MAINspecifies the primary independent file access address for microservicesENV_HAP_INTRANET_FILE_ENDPOINTfixed value "core:8880/file"- If the independent file address uses the default 80/443 port of http/https, you do not need to specify the default 80/443 port when configuring the above two variables.
Added port mapping instructions:
- 9000:9000maps the file service port in the container to the host to allow the nginx agent to access the file service in the next step
doc service variable modification instructions:
ENV_FILE_INNER_URI, the default variable value is changed tosc:9000
-
Restart the microservice
-
Add an nginx cross-origin proxy configuration for the primary independent file access address. You can refer to the following proxy configuration.
upstream file {server 192.168.0.10:9000; #Specify the IP of the backend microservice and map it to the file storage port on the microservice host}server {listen 80;server_name file-external.domain.com; #Specify the main independent address of the fileaccess_log /data/logs/weblogs/file-external.domain.com.log main; #Log path, customizableerror_log /data/logs/weblogs/file-external.domain.com.error.log; #Log path, customizablelocation / {if ($request_method = OPTIONS) {return 204 "";}proxy_set_header HOST $http_host;proxy_pass http://file;proxy_hide_header Access-Control-Allow-Origin;add_header Access-Control-Allow-Headers authorization,content-type;add_header Access-Control-Allow-Origin "http://example-external.domain.com"; #Specify the HDP system primary access address}} -
Add nginx cross-domain proxy configuration for file extension independent address. For the proxy configuration file, please refer to the configuration below.
upstream file {server 192.168.0.10:9000; #Specify the IP of the backend microservice and map it to the file storage port on the microservice host}server {listen 80;server_name file-internal.domain.com; #Specify file extension independent addressaccess_log /data/logs/weblogs/file-internal.domain.com.log main; #Log path, customizableerror_log /data/logs/weblogs/file-internal.domain.com.error.log; #Log path, customizablelocation / {if ($request_method = OPTIONS) {return 204 "";}proxy_set_header HOST $http_host;proxy_pass http://file;proxy_hide_header Access-Control-Allow-Origin;add_header Access-Control-Allow-Headers authorization,content-type;add_header Access-Control-Allow-Origin "http://example-internal.domain.com"; #HDP system extended access address}} -
Modify the agent of system extension address and add the request header
pdfileaddrfield underlocation /andlocation ~ /mds2respectively to specify the file extension independent address, as shown below......location / {set $real_ip '';if ($http_x_real_ip) {set $real_ip $http_x_real_ip;}if ($http_x_real_ip = '') {set $real_ip $remote_addr;}proxy_set_header X-Real-IP $real_ip;proxy_set_header Host $http_host;proxy_set_header X-Forwarded-Proto $scheme;proxy_set_header pdaddr http://example-internal.domain.com;proxy_set_header pdfileaddr http://file-internal.domain.com; #Added request header pdfileaddr to specify the file extension independent addressproxy_pass http://ext;}location ~ /mds2 {proxy_set_header Host $http_host;proxy_hide_header X-Powered-By;proxy_set_header X-NginX-Proxy true;proxy_pass http://ext;proxy_redirect off;proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection upgrade;proxy_set_header pdaddr http://example-internal.domain.com;proxy_set_header pdfileaddr http://file-internal.domain.com; #Added request header pdfileaddr to specify the file extension independent address}location ~ ^/(agent|api/workflow/api/sse/chat) {set $md_real_ip '';if ($http_x_real_ip) {set $md_real_ip $http_x_real_ip;}if ($http_x_real_ip = '') {set $md_real_ip $remote_addr;}proxy_buffering off;proxy_read_timeout 30m;proxy_send_timeout 30m;client_max_body_size 16m;proxy_set_header Host $host;proxy_set_header X-Real-IP $md_real_ip;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-HTTP-Method-Override "";proxy_set_header pdaddr http://example-internal.domain.com;proxy_set_header pdfileaddr http://file-internal.domain.com; #Added request header pdfileaddr to specify the file extension independent addressproxy_pass http://ext;proxy_redirect default;}...... -
After the proxy configuration is completed, clear the browser cache. You can then use the browser developer tools to see whether file-related requests have gone to independent addresses in Network.
Cluster environment
If the independent file storage address uses the default 80/443 port of http/https, you do not need to specify the default 80/443 port in the address when configuring the relevant environment variables.
System single access address
Here, the current system access address is http://example.domain.com and the new file independent address http://file.domain.com is taken as an example.
Configuration steps
-
Modify microservice related configurations
-
Modify microservice
config.yamland add environment variables:ENV_FILE_ADDRESS_MAIN: "http://file.domain.com"ENV_HAP_INTRANET_FILE_ENDPOINT: "www:8880/file"
-
-
ENV_FILE_ADDRESS_MAINenvironment variable value is the independent access address of the file-
Modify the microservice
service.yaml, find theENV_FILE_INNER_URIvariable of the doc service, and modify the variable value to the intranet address of the file storageenv:- name: ENV_FILE_INNER_URIvalue: "192.168.0.10:9000" #Change to the intranet address of file storage
-
-
Restart the microservice
-
Modify the file storage service
file.yamlconfiguration file, add relevant configurations and restart the file storage service-
Modify the file storage service
file.yamlconfiguration file and add the environment variableENV_FILE_DOMAINto specify an independent file address for the file storage service.ENV_FILE_DOMAIN: "http://file.domain.com"
-
-
Restart the file storage service
-
Add nginx cross-domain proxy configuration for file independent address. For the proxy configuration file, please refer to the configuration below.
upstream file {server 192.168.0.10:9000; #Specify the IP and port of the file storage service}server {listen 80;server_name file.domain.com; #Specify independent file addressaccess_log /data/logs/weblogs/file.domain.com.log main; #Log path, customizableerror_log /data/logs/weblogs/file.domain.com.error.log; #Log path, customizablelocation / {if ($request_method = OPTIONS) {return 204 "";}proxy_set_header HOST $http_host;proxy_pass http://file;proxy_hide_header Access-Control-Allow-Origin;add_header Access-Control-Allow-Headers authorization,content-type;add_header Access-Control-Allow-Origin "http://example.domain.com"; #Specify HDP system access address}} -
After the proxy configuration is completed, clear the browser cache. You can then use the browser developer tools to see whether file-related requests have gone to independent addresses in Network.
System multiple access addresses
In a system with multiple access addresses, when configuring independent addresses for file services, you need to configure an independent file address for each system access address.
Here we take the current system main access address example-external.domain.com and extended address example-internal.domain.com as an example.
Add two independent file access addresses file-external.domain.com and file-internal.domain.com to the two access addresses.
The corresponding relationship between system access address and file independent access address is as follows:
| Address type | Primary address | Extended address |
|---|---|---|
| System access address | example-external.domain.com | example-internal.domain.com |
| File independent address | file-external.domain.com | file-internal.domain.com |
Configuration steps
-
Modify microservice related configurations
-
Modify microservice
config.yamland add environment variables:ENV_FILE_ADDRESS_MAIN: "http://file-external.domain.com"ENV_HAP_INTRANET_FILE_ENDPOINT: "www:8880/file"
-
-
ENV_FILE_ADDRESS_MAINenvironment variable value is the primary independent access address of the file-
Modify the microservice
service.yaml, find theENV_FILE_INNER_URIvariable of the doc service, and modify the variable value to the intranet address of the file storageenv:- name: ENV_FILE_INNER_URIvalue: "192.168.0.10:9000" #Change to the intranet address of file storage
-
-
Restart the microservice
-
Modify the file storage service
file.yamlconfiguration file, add relevant configurations and restart the file storage service-
Modify the file storage service
file.yamlconfiguration file and add the environment variableENV_FILE_DOMAINto specify multiple independent file addresses for the file storage service.ENV_FILE_DOMAIN: "http://file-external.domain.com,http://file-internal.domain.com"
-
-
Restart the file storage service
-
Add nginx cross-domain proxy configuration for file master independent address. For the proxy configuration file, please refer to the configuration below.
upstream file {server 192.168.0.10:9000; #Specify the IP and port of the file storage service}server {listen 80;server_name file-external.domain.com; #Specify the main independent address of the fileaccess_log /data/logs/weblogs/file-external.domain.com.log main; #Log path, customizableerror_log /data/logs/weblogs/file-external.domain.com.error.log; #Log path, customizablelocation / {if ($request_method = OPTIONS) {return 204 "";}proxy_set_header HOST $http_host;proxy_pass http://file;proxy_hide_header Access-Control-Allow-Origin;add_header Access-Control-Allow-Headers authorization,content-type;add_header Access-Control-Allow-Origin "http://example-external.domain.com"; #Specify the HDP system primary access address}} -
Add nginx cross-domain proxy configuration for file extension independent address. For the proxy configuration file, please refer to the configuration below.
upstream file {server 192.168.0.10:9000; #Specify the IP and port of the file storage service}server {listen 80;server_name file-internal.domain.com; #Specify file extension independent addressaccess_log /data/logs/weblogs/file-internal.domain.com.log main; #Log path, customizableerror_log /data/logs/weblogs/file-internal.domain.com.error.log; #Log path, customizablelocation / {if ($request_method = OPTIONS) {return 204 "";}proxy_set_header HOST $http_host;proxy_pass http://file;proxy_hide_header Access-Control-Allow-Origin;add_header Access-Control-Allow-Headers authorization,content-type;add_header Access-Control-Allow-Origin "http://example-internal.domain.com"; #HDP system extended access address}} -
Modify the agent of system extension address and add the request header
pdfileaddrfield underlocation /andlocation ~ /mds2respectively to specify the file extension independent address, as shown below......location / {set $real_ip '';if ($http_x_real_ip) {set $real_ip $http_x_real_ip;}if ($http_x_real_ip = '') {set $real_ip $remote_addr;}proxy_set_header X-Real-IP $real_ip;proxy_set_header Host $http_host;proxy_set_header X-Forwarded-Proto $scheme;proxy_set_header pdaddr http://example-internal.domain.com;proxy_set_header pdfileaddr http://file-internal.domain.com; #Added request header pdfileaddr to specify the file extension independent addressproxy_pass http://ext;}location ~ /mds2 {proxy_set_header Host $http_host;proxy_hide_header X-Powered-By;proxy_set_header X-NginX-Proxy true;proxy_pass http://ext;proxy_redirect off;proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection upgrade;proxy_set_header pdaddr http://example-internal.domain.com;proxy_set_header pdfileaddr http://file-internal.domain.com; #Added request header pdfileaddr to specify the file extension independent address}location ~ ^/(agent|api/workflow/api/sse/chat) {set $md_real_ip '';if ($http_x_real_ip) {set $md_real_ip $http_x_real_ip;}if ($http_x_real_ip = '') {set $md_real_ip $remote_addr;}proxy_buffering off;proxy_read_timeout 30m;proxy_send_timeout 30m;client_max_body_size 16m;proxy_set_header Host $host;proxy_set_header X-Real-IP $md_real_ip;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-HTTP-Method-Override "";proxy_set_header pdaddr http://example-internal.domain.com;proxy_set_header pdfileaddr http://file-internal.domain.com; #Added request header pdfileaddr to specify the file extension independent addressproxy_pass http://ext;proxy_redirect default;}...... -
After the proxy configuration is completed, clear the browser cache. You can then use the browser developer tools to see whether file-related requests have gone to independent addresses in Network.