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 worksheet view contains numerous image files, clicking into such a view might lead to queued requests in the browser. In such cases, if the user navigates to another page before all requests are fully loaded, there might be a slowdown in browsing speed or even browser freezing.
To address this issue, it is essential first to ensure that sufficient resources and network bandwidth are available for the file service instance. Additionally, you can refer to this document to configure an independent address for file requests to prevent file requests from blocking other interface requests.
Single Host Environment
If the file storage independent address uses the default HTTP/HTTPS port of 80/443, it is not necessary to specify these default ports in the related environment variable configuration.
Single Access Address System
Taking the current system access address http://hap.domain.com
, and adding a file-independent address http://file.domain.com
as an example:
Configuration Steps
-
Modify the microservice
docker-compose.yaml
configuration file:version: '3'
services:
app:
image: registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-community:6.4.0
environment:
ENV_ADDRESS_MAIN: "http://hap.domain.com"
ENV_APP_VERSION: "6.4.0"
ENV_API_TOKEN: "******"
ENV_FILE_DOMAIN: "http://file.domain.com" # New variable specifying file independent address
ENV_FILE_ADDRESS_MAIN: "http://file.domain.com" # New variable specifying file independent address
ENV_HAP_INTRANET_FILE_ENDPOINT: "app:8880/file" # New variable with a fixed value
ports:
- 8880:8880
volumes:
- ./volume/data/:/data/
- ../data:/data/mingdao/data
sc:
image: registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-sc:3.2.0
environment:
<<: *app-environment
volumes:
- ./volume/data/:/data/
ports:
- 9000:9000 # New port mapping, maps container's 9000 port to the host
command:
image: registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-command:node1018-python36
doc:
image: registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-doc:2.0.0Explanation of the new variable configuration:
ENV_FILE_DOMAIN
: Specifies the file independent address for the file storage serviceENV_FILE_ADDRESS_MAIN
: Specifies the file independent address for the microserviceENV_HAP_INTRANET_FILE_ENDPOINT
: Fixed value "app:8880/file"- If the file independent address uses the default HTTP/HTTPS port of 80/443, you do not need to specify these default ports in the above two variables.
Explanation of the new port mapping:
- 9000:9000
maps the container's file service port to the host, allowing the subsequent Nginx proxy to access the file service.
Explanation of changes to the doc service variable:
ENV_FILE_INNER_URI
, default variable value changed tosc:9000
-
Restart the microservice.
-
Add Nginx cross-origin proxy configuration for the file independent address, a reference for the proxy configuration file is provided below:
upstream file {
server 192.168.0.10:9000; # Specify the backend microservice's IP along with the mapped file storage port on the microservice host
}
server {
listen 80;
server_name file.domain.com; # Specify the file independent address
access_log /data/logs/weblogs/file.domain.com.log main; # Log path, customizable
error_log /data/logs/weblogs/file.domain.com.error.log; # Log path, customizable
location / {
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://hap.domain.com"; # Specify the HAP system access address
}
} -
Clear the browser cache after the proxy configuration is complete. Then, you can use the browser developer tools to check in the Network tab if file-related requests are already directed to the independent address.
Multi Access Address System
In a multi-access address system, when configuring an independent address for file services, it is necessary to configure a file independent address for each system access address.
Taking the current system's main access address hap-external.domain.com
and extended address hap-internal.domain.com
as examples, independently add two file access addresses file-external.domain.com
and file-internal.domain.com
.
The correspondence between system access addresses and file independent access addresses is as follows:
Address Type | Main Address | Extended Address |
---|---|---|
System Access Address | hap-external.domain.com | hap-internal.domain.com |
File Independent Address | file-external.domain.com | file-internal.domain.com |
Configuration Steps
-
Modify the microservice
docker-compose.yaml
file, add the respective configurations, and then restart the microservice:version: '3'
services:
app:
image: registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-community:6.4.0
environment:
ENV_ADDRESS_MAIN: "http://hap-external.domain.com"
ENV_APP_VERSION: "6.4.0"
ENV_FILE_DOMAIN: "http://file-external.domain.com,http://file-internal.domain.com" # New variable, specifying multiple file independent addresses
ENV_FILE_ADDRESS_MAIN: "http://file-external.domain.com" # New variable, specifying the main file independent address
ENV_HAP_INTRANET_FILE_ENDPOINT: "app:8880/file" # New variable with a fixed value
ports:
- 8880:8880
- 18880:18880
volumes:
- ./volume/data/:/data/
- ../data:/data/mingdao/data
sc:
image: registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-sc:3.2.0
environment:
<<: *app-environment
volumes:
- ./volume/data/:/data/
ports:
- 9000:9000 # New port mapping, maps container's 9000 port to the host
command:
image: registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-command:node1018-python36
doc:
image: registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-doc:2.0.0Explanation of the new variable configuration:
ENV_FILE_DOMAIN
: Specifies multiple file independent addresses for the file storage serviceENV_FILE_ADDRESS_MAIN
: Specifies the main file independent address for the microserviceENV_HAP_INTRANET_FILE_ENDPOINT
: Fixed value "app:8880/file"- If the file independent address uses the default HTTP/HTTPS port of 80/443, you do not need to specify these default ports in the above variable configuration.
Explanation of the new port mapping:
- 9000:9000
maps the container's file service port to the host, allowing the subsequent Nginx proxy to access the file service.
Explanation of changes to the doc service variable:
ENV_FILE_INNER_URI
, default variable value changed tosc:9000
-
Restart the microservice.
-
Add Nginx cross-origin proxy configuration for the main file independent address, a reference for the proxy configuration file is provided below:
upstream file {
server 192.168.0.10:9000; # Specify the backend microservice's IP along with the mapped file storage port on the microservice host
}
server {
listen 80;
server_name file-external.domain.com; # Specify the main file independent address
access_log /data/logs/weblogs/file-external.domain.com.log main; # Log path, customizable
error_log /data/logs/weblogs/file-external.domain.com.error.log; # Log path, customizable
location / {
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://hap-external.domain.com"; # Specify the HAP system main access address
}
} -
Add Nginx cross-origin proxy configuration for the extended file independent address, a reference for the proxy configuration file is provided below:
upstream file {
server 192.168.0.10:9000; # Specify the backend microservice's IP along with the mapped file storage port on the microservice host
}
server {
listen 80;
server_name file-internal.domain.com; # Specify the extended file independent address
access_log /data/logs/weblogs/file-internal.domain.com.log main; # Log path, customizable
error_log /data/logs/weblogs/file-internal.domain.com.error.log; # Log path, customizable
location / {
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://hap-internal.domain.com"; # HAP system extended access address
}
} -
Modify the proxy for the system extended address, and add the
pdfileaddr
field to specify the extended file independent address underlocation /
andlocation ~ /mds2
, 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://hap-internal.domain.com;
proxy_set_header pdfileaddr http://file-internal.domain.com; # Add new header pdfileaddr, specifying the extended file independent address
proxy_pass http://hap-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://hap-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://hap-internal.domain.com;
proxy_set_header pdfileaddr http://file-internal.domain.com; # Add new header pdfileaddr, specifying the extended file independent address
}
...... -
Clear the browser cache after the proxy configuration is complete. Then, you can use the browser developer tools to check in the Network tab if file-related requests are already directed to the independent address.
Cluster Environment
If the file storage independent address uses the default HTTP/HTTPS port of 80/443, it is not necessary to specify these default ports in the related environment variable configuration.
Single Access Address System
Taking the current system access address http://hap.domain.com
and adding a file-independent address http://file.domain.com
as an example:
Configuration Steps
-
Modify related microservice configurations:
-
Modify the microservice
config.yaml
, adding the following environment variables:ENV_FILE_ADDRESS_MAIN: "http://file.domain.com"
ENV_HAP_INTRANET_FILE_ENDPOINT: "www:8880/file"ENV_FILE_ADDRESS_MAIN
: Environment variable value for the independent access address of the file.
-
Modify the microservice
service.yaml
, find theENV_FILE_INNER_URI
variable in the doc service, and change its value to the internal network address of the file storage:env:
- name: ENV_FILE_INNER_URI
value: "192.168.0.10:9000" # Changed to the internal network address of the file storage -
Restart the microservice.
-
-
Modify the file storage service
file.yaml
configuration file, add the relevant configuration, and then restart the file storage service:-
Modify the file storage service
file.yaml
configuration file, add the environment variableENV_FILE_DOMAIN
for specifying the file independent address for the file storage service:ENV_FILE_DOMAIN: "http://file.domain.com"
-
Restart the file storage service.
-
-
Add Nginx cross-origin proxy configuration for the file independent address, a reference for the proxy configuration is provided 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 the file independent address
access_log /data/logs/weblogs/file.domain.com.log main; # Log path, customizable
error_log /data/logs/weblogs/file.domain.com.error.log; # Log path, customizable
location / {
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://hap.domain.com"; # Specify the HAP system access address
}
} -
Clear the browser cache after the proxy configuration is complete. Then, you can use the browser developer tools to check in the Network tab if file-related requests are already directed to the independent address.
Multi Access Address System
In a multi-access address system, when configuring an independent address for file services, it is necessary to configure a file independent address for each system access address.
Taking the current system's main access address hap-external.domain.com
and extended address hap-internal.domain.com
as examples, independently add two file access addresses file-external.domain.com
and file-internal.domain.com
.
The correspondence between system access addresses and file independent access addresses is as follows:
Address Type | Main Address | Extended Address |
---|---|---|
System Access Address | hap-external.domain.com | hap-internal.domain.com |
File Independent Address | file-external.domain.com | file-internal.domain.com |
Configuration Steps
-
Modify related microservice configurations:
-
Modify the microservice
config.yaml
, adding the following environment variables:ENV_FILE_ADDRESS_MAIN: "http://file-external.domain.com"
ENV_HAP_INTRANET_FILE_ENDPOINT: "www:8880/file"ENV_FILE_ADDRESS_MAIN
: Environment variable value for the main independent access address of the file.
-
Modify the microservice
service.yaml
, find theENV_FILE_INNER_URI
variable in the doc service, and change its value to the internal network address of the file storage:env:
- name: ENV_FILE_INNER_URI
value: "192.168.0.10:9000" # Changed to the internal network address of the file storage -
Restart the microservice.
-
-
Modify the file storage service
file.yaml
configuration file, add the relevant configuration, and then restart the file storage service:-
Modify the file storage service
file.yaml
configuration file, add the environment variableENV_FILE_DOMAIN
to specify multiple file independent 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-origin proxy configuration for the main file independent address, a reference for the proxy configuration is provided 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 file independent address
access_log /data/logs/weblogs/file-external.domain.com.log main; # Log path, customizable
error_log /data/logs/weblogs/file-external.domain.com.error.log; # Log path, customizable
location / {
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://hap-external.domain.com"; # Specify the HAP system main access address
}
} -
Add Nginx cross-origin proxy configuration for the extended file independent address, a reference for the proxy configuration is provided 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 the extended file independent address
access_log /data/logs/weblogs/file-internal.domain.com.log main; # Log path, customizable
error_log /data/logs/weblogs/file-internal.domain.com.error.log; # Log path, customizable
location / {
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://hap-internal.domain.com"; # HAP system extended access address
}
} -
Modify the proxy for the system extended address, and add the
pdfileaddr
field to specify the extended file independent address underlocation /
andlocation ~ /mds2
, 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://hap-internal.domain.com;
proxy_set_header pdfileaddr http://file-internal.domain.com; # Add new header pdfileaddr, specifying the extended file independent address
proxy_pass http://hap-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://hap-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://hap-internal.domain.com;
proxy_set_header pdfileaddr http://file-internal.domain.com; # Add new header pdfileaddr, specifying the extended file independent address
}
...... -
Clear the browser cache after the proxy configuration is complete. Then, you can use the browser developer tools to check in the Network tab if file-related requests are already directed to the independent address.