...
代码块 |
---|
|
#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代理的地址,有如下情况:
...
代码块 |
---|
|
#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_redirect | proxy_cookie_path |
---|
http://ip/smartbi | http://ip:18080/smartbi | —— | —— | —— |
http://ip/bi | http://ip:18080/smartbi | —— | http://$host/smartbi /bi | /smartbi /bi |
http://ip | http://ip:18080/smartbi | —— | http://$host/smartbi / | /smartbi / |
http://ip | http://ip:18080/ | —— | —— | —— |
http://ip/bi | http://ip:18080/ | —— | http://$host/bi / | / /bi |
http://ip/oa/smartbi | http://ip:18080/smartbi | —— | http://$host/smartbi /oa/smartbi | / /oa/ |
http://ip:8088/smartbi | http://ip/smartbi | Host $host:$server_port | —— | —— |
https://ip/smartbi | http://ip:18080/smartbi | —— | http:// https:// | —— |
https://ip:8443/smartbi | http://ip:18080/smartbi | Host $host:$server_port | http:// https:// | —— |
https://ip/smartbi | https://ip:18443/smartbi | —— | —— | —— |
https://ip:8443/smartbi | https://ip:18443/smartbi | Host $host:$server_port | —— | —— |
https://ip/bi | https://ip:18443/smartbi | —— | —— | /smartbi /bi |