office online 外网访问静态资源无法获取

场景:

        服务器1:域控服务器 192.168.0.20

        服务器2:office online 服务器 192.168.0.10

        服务器3: nginx 服务器 192.168.0.30 端口80 【增加】centos7

配置了office online服务器ip的80端口的转发后在外网访问发现,office online 的访问的静态资源都是 http://192.168.0.10/mv/...的,因此导致无法使用。

方案一:

        修改office online 的源码

        因为文件较多,需要修改的较多,又可能修改遗漏。

方案二:

        增加服务器3 nginx服务器 。

        通过nginx代理,增加一个第三方的模块来做html内容替换解决,及在代理曾将

http://192.168.0.10:80 -> 替换为: http://外网ip:80

使用的第三方模块为:

ngx_http_substitutions_filter_module,来实现我们的各种需求。

经过测试,这个模块至少有如下实用功能:

①、支持多次替换

②、支持正则替换

③、支持中文替换

因为需要使用第三方模块,因此需要自己编译nginx 。

下载nginx源码。

nginx newshttp://nginx.org/我选择的最新版的1.21版本。

下载 ngx_http_substitutions_filter_module 源码

GitHub - yaoweibin/ngx_http_substitutions_filter_module: a filter module which can do both regular expression and fixed string substitutions for nginx

解压nginx源码,并将ngx_http_substitutions_filter_module源码解压到目录,如图:

安装依赖:

yum install -y openssl openssl-devel pcre zlib zlib-devel gcc

编译:

auto/configure

        --prefix=/software/nginx

        --add-module=ngx_http_substitutions_filter_module-master/

make

make install

修改配置文件:

location / {

     subs_filter_types text / html text / css text / xml ;

     subs_filter http://192.168.0.10:80 http://外网ip;

     subs_filter http://192.168.0.10 http://外网ip;

}

启动:

cd /software/nginx/sbin

./nginx 

通过外网地址访问,查看网页源码,发现已经替换。

源码以及编译好的文件:

使用centos7编译

链接:https://pan.baidu.com/s/1hI8a4aIbfojXZcqRPRFuAQ 
提取码:bwhi

windows10编译x86 32位 

nginx包含ngx_http_substitutions_filter_module的编译版本,

编译环境:

        vs 2019 nginx-1.23.1 、x86_32 windows10

链接:https://pan.baidu.com/s/14GohnQcDpkWHHCScMlGc7A 
提取码:cu8t

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值