私有部署-自定义路径前缀

业务场景 客户有一个主域名,所有的子产品通过路径访问,所以有数的页面地址、浏览器发起的请求路径、静态资源地址需要支持可自定义配置的路径前缀。

配置了自定义路径【DASH_PATH】后,有数BI相关的路径会加上 PUBLIC_PATH 前缀: https://xxx.com/${DASH_PATH}/xxx。dashPath 支持多级路径,比如 "/youshu/bi"。

示例

BI首页地址 https://demo.youdata.com/dash/home =》https://demo.youdata.com/youshu/dash/home

配置说明 环境变量 关联服务需要增加环境变量 DASH_PATH ,对应的值即用户配置的自定义路径。比如: DASH_PATH: /youdata

关联服务 web Inner web Inner web 还需要增加环境变量 IS_INNER_WEB:'true'

backend Website schedule Nginx配置 替换以下配置中 /youshu 为特定path:

worker_processes 2;
events {
  worker_connections 65535;
}

http {
  include       mime.types;
  default_type  application/octet-stream;
  client_max_body_size 1g;
  sendfile        on;
  keepalive_timeout 65;
  proxy_read_timeout 1200s;
  gzip on;
  gzip_comp_level 2;
  gzip_min_length 2k;
  gzip_types text/css text/javascript application/javascript image/svg+xml application/json;
  gzip_vary on;
  #隐藏版本号
  server_tokens off;

  log_format  main  '$remote_addr [$cookie_SESSION_YOUDATA] [$time_local] "$request" $status "$http_referer" $request_time $upstream_response_time';
  access_log /access.log main;

  server {
    listen 443;
    rewrite ^(.*)$ http://$host$1 permanent;
  }

  server {
    listen 8010;
    location / {
      proxy_pass http://backend:8010;
    }
  }

  upstream store {
    server store:9090;
  }

  server {
    listen 9090;
    location / {
      proxy_set_header Host $http_host;
      proxy_pass http://store;
    }
  }

  upstream web {
     server 1.1.1.1:7000;
  }

  upstream web-sticky-sameSite {
    server 1.1.1.1:7000;
    sticky name=YDNESIO expires=2h hmac=sha1 hmac_key=ydnesio secure sameSite=none;
  }
  upstream web-sticky {
    server 1.1.1.1:7000;
    sticky name=YDNESIO expires=2h hmac=sha1 hmac_key=ydnesio;
  }
  upstream inner-web-sticky {
    server 2.2.2.2:7000;
    sticky name=YDNESIO expires=2h hmac=sha1 hmac_key=ydnesio;
  }
  server {
    listen 7001;

    location ^~ /reportmis {
      resolver 127.0.0.11 valid=30s ipv6=off;
      set $cr2 complex-report;
      proxy_pass http://$cr2:8800;
    }

    location / {
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "Upgrade";
      proxy_set_header Host $http_host;
      proxy_set_header X-Forwarded-Host $http_host;
      proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
      proxy_pass http://inner-web-sticky;
    }
  }

  server {
    listen 80 default_server;

    location ^~ /youshu/index/ {
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_pass http://website:9000/index/;
    }

    location ^~ /youshu/mammutAdapter/api/ {
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_pass http://mammut-adapter:8888/api/;
    }

    location ^~ /youshu/dash/socket.io/ {
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "Upgrade";
      proxy_set_header Host $http_host;
      proxy_set_header X-Forwarded-Host $http_host;
      proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
      set $backend "web-sticky";
      if ($cookie_YOUDATA.sameSite) {
        set $backend "web-sticky-sameSite";
      }
      proxy_pass http://$backend;
    }

    location = /youshu/dash/store/webrpc {
        return 403;
    }

    location ^~ /youshu/dash/store/ {
      proxy_set_header Host nginx:9090;
      proxy_pass http://store/;
    }

    location ^~ /youshu/operation/ {
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_pass http://backend:8010;
    }

    location ^~ /reportmis {
      resolver 127.0.0.11 valid=30s ipv6=off;
      set $cr complex-report;
      proxy_pass http://$cr:8800;
    }

    # 监控需要同步配置
    location ~ /youshu/monitor {
      resolver 127.0.0.11 valid=30s ipv6=off;
      set $gf grafana;
      proxy_pass http://$gf:3000;
    }

    location /youshu/ {
      proxy_set_header Host $http_host;
      proxy_set_header X-Forwarded-Host $http_host;
      proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
      proxy_pass http://web;
    }
  }
}

stream {
  upstream redis {
    server redis:6379;
  }

  server {
    listen 6379;
    proxy_timeout 30m;
    proxy_pass redis;
  }

# The below config is for using gpfdist in DE
# To use gpfist, please make sure that the servers of MPP can connect to the Youdata BI servers
# and decomment the below config and the gploader in the stack yaml file.
#    upstream gploader_stream {
#        server gploader:8090;
#    }
#    server {
#        listen 8070;
#        proxy_pass gploader_stream;
#    }
}
Demo环境nginx备份

worker_processes 2;
events {
  worker_connections 65535;
}

http {
  include       mime.types;
  default_type  application/octet-stream;
  client_max_body_size 1g;
  sendfile        on;
  keepalive_timeout 65;
  proxy_read_timeout 1200s;
  gzip on;
  gzip_comp_level 2;
  gzip_min_length 2k;
  gzip_types text/css text/javascript application/javascript image/svg+xml application/json;
  gzip_vary on;
  #隐藏版本号
  server_tokens off;

  log_format  main  '$remote_addr [$cookie_SESSION_YOUDATA] [$time_local] "$request" $status "$http_referer" $request_time $upstream_response_time';
  access_log /access.log main;

  server {
    listen 443;
    rewrite ^(.*)$ http://$host$1 permanent;
  }

  server {
    listen 8010;
    location / {
      resolver 127.0.0.11 valid=30s ipv6=off;
      set $svc backend;
      proxy_pass http://$svc:8010;
    }
  }

  upstream store {
    server store:9090;
  }

  server {
    listen 9090;
    location / {
      proxy_set_header Host $http_host;
      proxy_pass http://store;
    }
  }

  upstream web {
     server 1.1.1.1:7000;
  }

  upstream web-sticky-sameSite {
    server 1.1.1.1:7000;
    sticky name=YDNESIO expires=2h hmac=sha1 hmac_key=ydnesio secure sameSite=none;
  }
  upstream web-sticky {
    server 1.1.1.1:7000;
    sticky name=YDNESIO expires=2h hmac=sha1 hmac_key=ydnesio;
  }
  upstream inner-web-sticky {
    server 2.2.2.2:7000;
    sticky name=YDNESIO expires=2h hmac=sha1 hmac_key=ydnesio;
  }
  server {
    listen 7001;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-Host $http_host;
    proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;

    location ^~ /reportmis {
      resolver 127.0.0.11 valid=30s ipv6=off;
      set $cr2 complex-report;
      proxy_pass http://$cr2:8800;
    }

    location / {
      proxy_set_header Host $http_host;
      proxy_set_header X-Forwarded-Host $http_host;
      proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "Upgrade";
      proxy_pass http://inner-web-sticky;
    }
  }



  server {
    listen 80 default_server;
    resolver 127.0.0.11 valid=30s ipv6=off;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-Host $http_host;
    proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;


    location ^~ /youdata/index/ {
      set $svc website;
      proxy_pass http://$svc:9000;
    }

    location ^~ /youdata/api/dash {
      add_header Cache-Control no-store;
      proxy_pass http://web;
    }

    location ^~ /youdata/dash/socket.io/ {
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "Upgrade";
      set $webs "web-sticky";
      if ($cookie_YOUDATA.sameSite) {
        set $webs "web-sticky-sameSite";
      }
      proxy_pass http://$webs;
    }

    location = /youdata/dash/store/webrpc {
        return 403;
    }

    location ^~ /youdata/dash/store/ {
      proxy_set_header Host nginx:9090;
      proxy_pass http://store/;
    }

    location ^~ /youdata/operation {
      set $svc backend;
      proxy_pass http://$svc:8010;
    }

    location ^~ /youdata/cache {
      set $sc smartcache;
      proxy_pass http://$sc:7002;
    }

    location ^~ /youdata/reportmis/ {
      set $cr complex-report;
      proxy_pass http://$cr:8800/reportmis/;
    }

    location ~ /youdata/monitor {
      set $gf grafana;
      proxy_pass http://$gf:3000;
    }

    location /youdata/ {
      proxy_pass http://web;
    }
  }
}

stream {
  upstream redis {
    server redis:6379;
  }

  server {
    listen 6379;
    proxy_timeout 30m;
    proxy_pass redis;
  }

# The below config is for using gpfdist in DE
# To use gpfist, please make sure that the servers of MPP can connect to the Youdata BI servers
# and decomment the below config and the gploader in the stack yaml file.
#    upstream gploader_stream {
#        server gploader:8090;
#    }
#    server {
#        listen 8070;
#        proxy_pass gploader_stream;
#    }
}