(nginx的方案源于网上资料,本文档仅供参考)
背景
直接访问smartbi地址是http协议的,但是由于实际的安全需要通过nginx修改成了https协议的地址,此时用户通过https协议的地址访问smartbi可能会出现各种问题。
有问题的nginx配置如下:
#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
client_max_body_size 80m;
client_body_buffer_size 10m;
sendfile on;
tcp_nopush on;
keepalive_timeout 120;
server_tokens off;
server {
listen 80 ;
listen 443 ssl;
server_name www.xxx.com;
access_log logs/www.xxx.com.log;
error_log logs/www.xxx.com.log;
ssl_certificate ssl/xxx.com.crt;
ssl_certificate_key ssl/xxx.com.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
root html;
index index.html index.htm index.php;
location / {
proxy_pass http://10.10.202.17:18080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_max_temp_file_size 0;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
}
}
现象
类似上述配置在通过https协议的地址访问smartbi时可能会出现如下问题:
1、在界面上无法导出资源、系统日志、备份知识库;
2、打开报表点导出按钮无法导出文件;
3、集成时通过https格式的含openresource.jsp加参数的的方式无法打开自助仪表盘资源;
4、配置了域名,部署了企业微信扩展包配置正确,在smartbi推送报表到企业微信后也正常,但是通过企业微信app无法正常打开报表(出现404等错误);
解释
出现上述问题的原因在于https协议的地址在重定向后变成了http,本质是浏览器重定向时nginx错误的告知浏览器使用了proxy_pass地址(原始smartbi地址)的http协议。
解决方案
对于上述配置文件,有如下三种解决方案:
1、删除location /大括号中的 proxy_set_header Host $host;
原因:配置$host会导致重定向时采用代理后应用系统的协议,因此需要移除,nginx内置的proxy_set_header Host默认值是$proxy_host,按默认值即可正常重定向。
2、将location /大括号中的 proxy_set_header Host $host;修改成proxy_set_header Host $http_host;
在有域名映射时常常可以通过此方案解决。
3、其他配置不修改,只在location /大括号中增加一行如下配置:
proxy_redirect http:// https://;
这一行的含义是在重定向时遇到http://开头的地址全部替换成https://
依次采用上述解决方案修改配置后重载nginx测试,一般至少有一个方案能解决。
若实际场景的nginx配置文件与上述不一致(比如定义了多个location),应在smartbi匹配度最高的location中尝试上述三个方案。
Viewtracker License Missing
There is a problem with the license of the Viewtracker addon. Please check if you have a valid license.
授权码细节