dremio nginx proxy 问题简单说明二
以前说过基于修改dremio 服务的静态index.html 实际上还有一种方法就是直接通过nginx 的sub_filter 指令,以下是简单说明
配置
核心是nginx ,后端服务就不需要修改了
- nginx.conf
核心是sub_filter 的匹配处理
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
real_ip_header X-Forwarded-For;
real_ip_recursive on;
server {
listen 80;
server_name localhost;
charset utf-8;
root /usr/share/nginx/html;
location = /vlake/ {
sub_filter '</body>' '<script > history.pushState({}, "default", "/");</script></body>';
sub_filter_types text/html;
sub_filter_once off;
proxy_set_header Accept-Encoding '';
proxy_pass http://dremio:9047/index.html;
}
location = /vlake/index.html {
sub_filter '</body>' '<script > history.pushState({}, "default", "/");</script></body>';
sub_filter_types text/html;
sub_filter_once off;
proxy_set_header Accept-Encoding '';
proxy_pass http://dremio:9047;
}
location @dremio {
proxy_http_version 1.1;
rewrite ^/vlake/(.*)$ /$1 break;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
proxy_pass http://dremio:9047;
}
location /login {
proxy_pass http://dremio:9047/index.html;
}
location ^~ /static/ {
proxy_pass http://dremio:9047;
}
location /manifest.webmanifest {
return 200;
}
location /apiv2/ {
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
proxy_pass http://dremio:9047/apiv2/;
}
location /api/v3/ {
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
proxy_pass http://dremio:9047/api/v3/;
}
location ^~ /jobs/ {
proxy_pass http://dremio:9047/index.html;
}
# location ^~ /vlake/new_query/ {
# rewrite ^/(.*)/$ /vlake/$1/index.html break;
# proxy_pass http://dremio:9047;
# }
# location ^~ /new_query/ {
# rewrite ^/(.*)/$ /vlake/$1/index.html break;
# proxy_pass http://dremio:9047;
# }
location ^~ /vs/ {
proxy_pass http://dremio:9047/vs/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
说明
以上是一个简单说明,处理上基于nginx 的sub_filter 处理简单快速,配置我已经push github 了可以参考
参考资料
https://github.com/rongfengliang/nginx-dremio-proxy/tree/dev
https://nginx.org/en/docs/http/ngx_http_sub_module.html