1. 编辑 i2Share 配置文件/data/i2share/webhub_settings.py
增加AUTO_FILE_SERVER_ROOT_PATH = 'filehttp'
停止服务i2share-admin stop
启动服务i2share-admin start
2.修改 nginx 配置文件/etc/nginx/conf.d/i2share.conf
增加server监听内网的800端口
执行 nginx -s reload 使配置生效
3.改完后外网依旧无法下载,打开浏览器debug模式发现下载地址端口不对,将端口写入文件
map $host $the_port {
default $http_x_forwarded_port;
"106.41.69.46" "8000";
}
配置如下
gzip on; #开启Gzip
gzip_min_length 1k; #不压缩临界值,大于1K的才压缩
gzip_comp_level 3; #压缩级别,1-10,数字越大压缩性能的越好,越消耗服务器资源
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/gif image/png; #进行压缩的文件,切勿添加jpg
gzip_vary on;
gzip_disable "MSIE [1-6]\.";
map $http_x_forwarded_proto $the_scheme {
default $http_x_forwarded_proto;
"" $scheme;
}
map $http_x_forwarded_host $the_host {
default $http_x_forwarded_host;
"" $host;
}
map $http_upgrade $proxy_connection {
default upgrade;
"" close;
}
map $http_x_forwarded_port $the_port {
default $http_x_forwarded_port;
"" $server_port;
}
map $host $the_port {
default $http_x_forwarded_port;
"106.41.69.46" "8000";
}
server {
listen 80;
server_name 192.168.0.8; # 请替换$I2SHARE_SERVER_IP_OR_DOMAIN为实际的服务器接入IP或域名
server_tokens off;
proxy_set_header X-Forwarded-For $remote_addr;
if ($request_method !~* GET|POST|PUT|DELETE|HEAD) {
return 405;
}
set $lang $http_accept_language;
if ($http_accept_language ~* ^zh-Hant){
set $lang "zh-Hant";
}
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $the_host;
proxy_set_header X-Forwarded-Port $the_port;
proxy_set_header X-Forwarded-Proto $the_scheme;
proxy_set_header Accept-Language $lang;
proxy_read_timeout 1200s;
# used for view/edit office file via Office Online Server
client_max_body_size 0;
access_log /var/log/nginx/i2share.access.log;
error_log /var/log/nginx/i2share.error.log;
}
location /filehttp {
rewrite ^/filehttp(.*)$ $1 break;
proxy_pass http://127.0.0.1:8082;
client_max_body_size 0;
proxy_connect_timeout 36000s;
proxy_read_timeout 36000s;
proxy_max_temp_file_size 0;
proxy_buffering off;
}
location /media {
root /data/i2share/i2share-server/websvr;
}
location /frontend {
root /data/i2share/i2share-server/websvr;
}
# 如需使用onlyoffice服务作为在线编辑第三方组件,请取消以下注释并填写onlyoffice服务的URL值
#location /onlyofficeds/ {
# # THIS ONE IS IMPORTANT ! - Trailing slash !
# # 在线编辑服务地址
# proxy_pass $ONLYOFFICE_SERVICE_URL; #请替换$ONLYOFFICE_SERVICE_URL为onlyoffice服务的URL,URL最后必须以"/"结尾
# proxy_http_version 1.1;
# client_max_body_size 100M; # 限制文档最大尺寸为100M
# proxy_read_timeout 3600s;
# proxy_connect_timeout 3600s;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection $proxy_connection;
# # THIS ONE IS IMPORTANT ! - Subfolder and NO trailing slash !
# proxy_set_header X-Forwarded-Host $the_host/onlyofficeds;
# proxy_set_header X-Forwarded-Proto $the_scheme;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#}
# 如需支持webdav,请取消以下注释
#location /i2sharedav {
# proxy_pass http://127.0.0.1:8080;
# proxy_set_header Host $http_host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header X-Forwarded-Host $the_host;
# proxy_set_header X-Forwarded-Port $the_port;
# proxy_set_header X-Forwarded-Proto $scheme;
# proxy_set_header Accept-Language $lang;
# proxy_read_timeout 1200s;
# client_max_body_size 0;
# proxy_max_temp_file_size 0;
# proxy_buffering off;
# access_log /var/log/nginx/i2share.webdav.access.log;
# error_log /var/log/nginx/i2share.webdav.error.log;
#}
}
server {
listen 800;
server_name 106.41.69.46; # 请替换$I2SHARE_SERVER_IP_OR_DOMAIN为实际的服务器接入IP或域名
server_tokens off;
proxy_set_header X-Forwarded-For $remote_addr;
if ($request_method !~* GET|POST|PUT|DELETE|HEAD) {
return 405;
}
set $lang $http_accept_language;
if ($http_accept_language ~* ^zh-Hant){
set $lang "zh-Hant";
}
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $the_host;
proxy_set_header X-Forwarded-Port $the_port;
proxy_set_header X-Forwarded-Proto $the_scheme;
proxy_set_header Accept-Language $lang;
proxy_read_timeout 1200s;
# used for view/edit office file via Office Online Server
client_max_body_size 0;
access_log /var/log/nginx/i2share.access.log;
error_log /var/log/nginx/i2share.error.log;
}
location /filehttp {
rewrite ^/filehttp(.*)$ $1 break;
proxy_pass http://127.0.0.1:8082;
client_max_body_size 0;
proxy_connect_timeout 36000s;
proxy_read_timeout 36000s;
proxy_max_temp_file_size 0;
proxy_buffering off;
}
location /media {
root /data/i2share/i2share-server/websvr;
}
location /frontend {
root /data/i2share/i2share-server/websvr;
}
# 如需使用onlyoffice服务作为在线编辑第三方组件,请取消以下注释并填写onlyoffice服务的URL值
#location /onlyofficeds/ {
# # THIS ONE IS IMPORTANT ! - Trailing slash !
# # 在线编辑服务地址
# proxy_pass $ONLYOFFICE_SERVICE_URL; #请替换$ONLYOFFICE_SERVICE_URL为onlyoffice服务的URL,URL最后必须以"/"结尾
# proxy_http_version 1.1;
# client_max_body_size 100M; # 限制文档最大尺寸为100M
# proxy_read_timeout 3600s;
# proxy_connect_timeout 3600s;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection $proxy_connection;
# # THIS ONE IS IMPORTANT ! - Subfolder and NO trailing slash !
# proxy_set_header X-Forwarded-Host $the_host/onlyofficeds;
# proxy_set_header X-Forwarded-Proto $the_scheme;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#}
# 如需支持webdav,请取消以下注释
#location /i2sharedav {
# proxy_pass http://127.0.0.1:8080;
# proxy_set_header Host $http_host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header X-Forwarded-Host $the_host;
# proxy_set_header X-Forwarded-Port $the_port;
# proxy_set_header X-Forwarded-Proto $scheme;
# proxy_set_header Accept-Language $lang;
# proxy_read_timeout 1200s;
# client_max_body_size 0;
# proxy_max_temp_file_size 0;
# proxy_buffering off;
# access_log /var/log/nginx/i2share.webdav.access.log;
# error_log /var/log/nginx/i2share.webdav.error.log;
#}
}