页面树结构

版本比较

标识

  • 该行被添加。
  • 该行被删除。
  • 格式已经改变。
评论: 常用设置参考

...

代码块
languagejs
collapsetrue
#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代理的地址,有如下情况:

...

代码块
languagejs
collapsetrue
#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;
    } 
	}
}

常见场景下的proxy_set_header、proxy_redirect和proxy_cookie_path设置参考

注:表中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://$host/bi  //  /bi
http://ip/oa/smartbihttp://ip:18080/smartbi——http://$host/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————/smartbi  /bi



Viewtracker