Github user okoethibm commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17455#discussion_r109588861
  
    --- Diff: core/src/main/scala/org/apache/spark/deploy/master/Master.scala 
---
    @@ -132,7 +132,13 @@ private[deploy] class Master(
         webUi.bind()
         masterWebUiUrl = "http://"; + masterPublicAddress + ":" + 
webUi.boundPort
         if (reverseProxy) {
    -      masterWebUiUrl = conf.get("spark.ui.reverseProxyUrl", masterWebUiUrl)
    +      conf.getOption("spark.ui.reverseProxyUrl") map { reverseProxyUrl =>
    +        val proxyUrlNoSlash = reverseProxyUrl.stripSuffix("/")
    +        System.setProperty("spark.ui.proxyBase", proxyUrlNoSlash)
    +        // If the master URL has a path component, it must end with a 
slash.
    +        // Otherwise the browser generates incorrect relative links
    +        masterWebUiUrl = proxyUrlNoSlash + "/"
    --- End diff --
    
    If we have a front-end reverse proxy path like 
mydomain.com:80/path/to/spark, then the spark.ui.proxyBase property (prefix for 
URL generation) *must not* include a trailing slash, the way it's used in 
UiUtils, like prependBaseUri("/static/bootstrap.min.css"). 
    However, the explicit URL address pointing to the master UI page (e.g. the 
back-lilnk from workers to master, which masterWebUiUrl feeds into) *must* 
include a trailing slash, if it has a path component, because the master UI 
page contains relative liks like "app?...".
    Without a path component, the trailing slash does not matter for resolving 
these links, but with a path component, they must resolve to 
mydomain.com:80/path/to/spark/app (*not* mydomain.com:80/path/to/app), 
therefore the base URL must have a trailing slash.
    
    The code is intended to work regardless whether spark.ui.reverseProxyUrl 
was specified with or without a trailing slash, so the safe way to ensure a 
single trailing slash was to first strip an optional slash and then add one. 
Your suggestion would double the slash if there is one specified in the config.
    If there's a clean way to move the stripSuffix handling into the config 
itself, that would make the code prettier, though



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to