onlyoffice配置
onlyoffice层配置别名请求,解决多数场景下,系统只有一个请求入口的情况。
目前这里只附加nginx配置 ,后续补充部署配置:别名统一为:my_office
这里主要需要代理的有api.js的入口路径和cache的文件库路径。
cache路径需要修配office的default.json配置,修改如下:
storage:{
"bucketName":"my_office/cache"
}
nginx配置如下:
map $http_host $this_host {
"" $host;
default $http_host;
}
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;
"" $this_host;
}
map $http_upgrade $proxy_connection {
default upgrade;
"" close;
}
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $proxy_connection;
proxy_set_header X-Forwarded-Host $the_host;
proxy_set_header X-Forwarded-Proto $the_scheme;
server {
listen 0.0.0.0:8093;
listen [::]:8093 default_server;
server_tokens off;
rewrite ^\/OfficeWeb(\/apps\/.*)$ /web-apps$1 redirect;
location /sino_office/ {
proxy_pass http://localhost:8000/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 3600s; # 设置较长的超时时间
}
location /sino_office/cache/ {
proxy_pass http://localhost:8000/sino_office/cache/;
proxy_http_version 1.1;
}
}
外层代理配置,统一入口,后续可以在这里添加负载均衡:
server {
listen 80;
server_name _;
location /sino_office {
# 基本代理设置
proxy_pass http://192.168.1.135:8093/my_office/;
# 请求头设置(包含端口信息)
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
# WebSocket 支持
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 3600s; # 设置较长的超时时间
}
}
License:
CC BY 4.0