我在nginx代理后面运行Spark 2.1.1独立集群,具有以下相关配置:
在git checkout b/<branch-name> -- ./Source/Models
spark-defaults.conf
在nginx网站配置
spark.ui.reverseProxy true
spark.ui.reverseProxyUrl http://<mydomain>/spark
当我访问应用程序UI的页面时,例如以下内容:
location /spark/ {
proxy_pass http://spark-master:8080/;
proxy_set_header Accept-Encoding '';
sub_filter '/static/' '/spark/static/';
sub_filter '/proxy/' '/spark/proxy/';
sub_filter_once off;
}
它们看起来非常混乱,因为它们被设置到错误的位置时无法找到相关的CSS和Javascript文件,例如以下CSS文件:
http://<my domain>/spark/proxy/app-20170831014128-0000/jobs/
我认为它应该设置在以下位置:
http://<my domain>/spark/proxy/app-20170831014128-0000/spark/static/bootstrap.min.css
所以目前,我通过在nginx上添加http://<my domain>/spark/static/bootstrap.min.css
指令来解决这个问题,如下所示:
rewrite
这是一个快速而肮脏的工作。因为我在搜索互联网后找不到更好的解决方案,所以我怀疑我的设置可能有问题。
有人有建议去哪看吗?或者这是Spark的已知问题?
非常感谢您的帮助。
答案 0 :(得分:2)
在spark-defaults.conf
上添加:
spark.ui.proxyBase /spark
并在nginx网站配置中删除此内容:
sub_filter '/static/' '/spark/static/';
编辑:
添加我的完整配置,它适用于版本2.2.0。
spark-defaults.conf
config:
spark.ui.proxyBase /sparkui
spark.ui.reverseProxy true
spark.ui.reverseProxyUrl https://<domain>/sparkui
nginx config:
location /sparkui/ {
proxy_pass http://<master>:8080/;
proxy_set_header Accept-Encoding '';
sub_filter '="/proxy/' '="/sparkui/proxy/';
sub_filter_once off;
}
我找到了这个PR https://github.com/apache/spark/pull/17455,它修复了反向代理路径问题。这个PR可能合并到2.3.0。另一种方式是https://github.com/aseigneurin/spark-ui-proxy,但我不会尝试。
答案 1 :(得分:0)
我目前的解决方案基本上遵循了eshizhan的建议,并进行了一些额外的更改,如下所示:
在spark-defaults.conf
spark.ui.reverseProxy true
spark.ui.proxyBase /spark
spark.ui.reverseProxyUrl http://<my domain>
在nginx网站配置
location /spark/ {
proxy_pass http://spark-master:8080/;
proxy_set_header Accept-Encoding '';
sub_filter '/proxy/' '/spark/proxy/';
sub_filter '">Back to Master<' '/spark/">Back to Master<';
sub_filter_once off;
}
它仍然看起来很难看,因为似乎没有必要在 Back to Master URL上设置spark.ui.reverseProxyUrl
和黑客。但至少几乎所有的 URL现在都在我的浏览器上正确呈现。
有人有其他建议吗?