页面树结构
转至元数据结尾
转至元数据起始

(nginx的方案源于网上资料,本文档仅供参考)

背景

直接访问smartbi地址应用名称是smartbi,但是由于实际需要通过nginx修改了应用名称,或者在smartbi应用前添加了一层应用名,如smartbi地址为:http://10.10.12.91:18080/smartbi,通过nginx修改了应用名增加了一层路径,地址是:http://10.10.12.91/oa/smartbi,此时是容易出现较多问题的。

注:本文中oa仅作为示例,实际配置如果配置的名称不一致,则nginx配置文件中对应的oa都要修改成实际的路径。

初始nginx.conf配置如下:

#user  root root;                                                                
worker_processes  1;                                                           
events {                                                                        
    worker_connections  1024;                                                   
}                                                                               
http {
	include  mime.types;
	default_type application/octet-stream;
	sendfile  on;
	keepalive_timeout 65;
	server {
    listen       80;
    server_name  localhost 10.10.12.91 ;
    #charset koi8-r;
    
    resolver 8.8.8.8;
     location ^~ /oa/  {
            proxy_pass         http://10.10.12.91: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;
            client_max_body_size 100m;
            client_body_buffer_size 128k;
            proxy_connect_timeout 90;
            proxy_send_timeout 300;
            proxy_read_timeout 300;
            proxy_buffer_size 4k;
            proxy_buffers 4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    } 
	}
}
 

现象和解决方案

基于上述配置访问nginx代理的地址,有如下情况:

1、访问代理后的地址出现404

现象:

(1)访问http://10.10.12.91/oa/smartbi跳转到http://10.10.12.91/smartbi/,页面显示404;

如果访问http://10.10.12.91/oa/smartbi/vision/index.jsp,则不会出现404

(2)集成时通过

解释:

此问题原因在于nginx没有配置好重定向,因为在访问http://10.10.12.91/oa/smartbi或者通过openresource.jsp的方式打开自助仪表盘资源时smartbi都会进行重定向,nginx配置文件没有配置重定向的规则导致重定向的地址没有拼接/oa名称从而出现404

解决方案:

在nginx.conf文件location节点中增加配置:proxy_redirect http://$host/smartbi /oa/smartbi;

如果该配置未解决,可使用:proxy_redirect /smartbi /oa/smartbi;

如图:

保存配置,重启nginx。

 

2、访问代理后的登录页登录闪退

现象:

在配置好问题1的重定向重启nginx后,正常访问系统首页,输入正确的用户名和密码,点击登录,弹窗提示会话超时并且一闪而过,如图:

解释:

此问题原因在于nginx没有配置好新项目名称的cookie,因为smartbi是通过cookie path来判断用户是否登录成功的,nginx配置文件没有配置好cookie重写导致cookie路径不对,smartbi在获取获取时无法获取到对应路径的cookie因此认为用户未登录,从而弹出会话超时跳转到登录页。

解决方案:

在nginx.conf文件location节点中增加配置:proxy_cookie_path / /oa/;

保存配置,重启nginx。最终的nginx.conf配置如下:

#user  root root;                                                                
worker_processes  1;                                                           
events {                                                                        
    worker_connections  1024;                                                   
}                                                                               
http {
	include  mime.types;
	default_type application/octet-stream;
	sendfile  on;
	keepalive_timeout 65;
	server {
    listen       80;
    server_name  localhost 10.10.12.91 ;
    #charset koi8-r;
    
    resolver 8.8.8.8;
     location ^~ /oa/  {
            proxy_pass         http://10.10.12.91: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_redirect http://$host/smartbi /oa/smartbi;
            client_max_body_size 100m;
            client_body_buffer_size 128k;
            proxy_connect_timeout 90;
            proxy_send_timeout 300;
            proxy_read_timeout 300;
            proxy_buffer_size 4k;
            proxy_buffers 4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
            proxy_cookie_path / /oa/;
        }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    } 
	}
}

注:表中ip指局域网或广域网的ip/域名,——表示不需要该设置(即按nginx内置的默认值可以正常代理请求)

nginx代理后的smartbi地址smartbi原始地址

proxy_set_header

proxy_redirect

proxy_cookie_path

http://ip/smartbihttp://ip:18080/smartbi——————
http://ip/bihttp://ip:18080/smartbi——http://$host/smartbi /bi/smartbi /bi
http://iphttp://ip:18080/smartbi——http://$host/smartbi/ //smartbi /
http://iphttp://ip:18080/——————
http://ip/bihttp://ip:18080/——http://$http_host /bi 或http://$host /bi/ /bi
http://ip/oa/smartbihttp://ip:18080/smartbi——

http://$host/smartbi /oa/smartbi 或

/smartbi /oa/smartbi;

/ /oa/
http://ip:8088/smartbihttp://ip/smartbiHost             $host:$server_port————
https://ip/smartbihttp://ip:18080/smartbi——http:// https://——
https://ip:8443/smartbihttp://ip:18080/smartbiHost             $host:$server_porthttp:// https://——
https://ip/smartbihttps://ip:18443/smartbi——————
https://ip:8443/smartbihttps://ip:18443/smartbiHost             $host:$server_port————
https://ip/bihttps://ip:18443/smartbi——https://$host/smartbi /bi/smartbi /bi
https://iphttps://ip:18443/smartbi——https://$host/smartbi //smartbi /



Viewtracker License Missing

There is a problem with the license of the Viewtracker addon. Please check if you have a valid license.

授权码细节