title: Define prefix for static resource paths in bokeh with autoload.js
body: <p>I have a service that spins up Bokeh server instances like so:</p>
  
  <pre><code>server = Server({"/": app}, io_loop=loop, port=port, 
  allow_websocket_origin=['localhost:%d'%port, origin, self.request.host])
  </code></pre>
  
  <p>This service runs behind a proxy (<a href="https://github.com/jupyterhub/nbserverproxy" rel="nofollow noreferrer">nbserverproxy</a>) such that the client can only access <code>localhost:&lt;port&gt;/&lt;path&gt;</code> via <code>example.com/proxy/&lt;port&gt;/&lt;path&gt;</code></p>
  
  <p>I am trying to return a script tag that will load my bokeh app ensuring that resources are requested from <code>example.com/proxy/&lt;port&gt;/&lt;path&gt;</code></p>
  
  <p>Currently I generate this tag like so:</p>
  
  <pre><code>script = """&lt;script
          src="{protocol}://{origin}{prefix}autoload.js?bokeh-autoload-element={ele_id}&amp;bokeh-absolute-url={protocol}://{origin}&amp;bokeh-app-path={prefix}"
          id="{ele_id}"
          data-bokeh-model-id=""
          data-bokeh-doc-id=""
      &gt;&lt;/script&gt;""".format(protocol=protocol, origin=origin, prefix=prefix, ele_id=ele_id) 
  </code></pre>
  
  <p>which (for bokeh running on port 45740 renders something like:</p>
  
  <pre><code>&lt;script
          src="https://example.com/proxy/45740/autoload.js?bokeh-autoload-element=0535b6ca-6af2-4fcf-aa51-66d642fd3b08&amp;bokeh-absolute-url=http://localhost:8888&amp;bokeh-app-path=/proxy/45740/"
          id="0535b6ca-6af2-4fcf-aa51-66d642fd3b08"
          data-bokeh-model-id=""
          data-bokeh-doc-id=""
      &gt;&lt;/script&gt;
  </code></pre>
  
  <p>This tag will correctly return some Javascript unfortunately in this JS it will try to load the JS / CSS resources at a location like:</p>
  
  <p><code>https://example.com/static/js/bokeh.min.js</code></p>
  
  <p>rather than </p>
  
  <p><code>https://example.com/proxy/45740/static/js/bokeh.min.js</code></p>
  
  <p>I can't figure a way to tell bokeh that it's behind a proxy such that all paths start '/proxy/45740/' from the client's perspective.</p>
  
  <p>I have tried starting the server with the <code>prefix</code> arg like:</p>
  
  <p><code>Server({"/": app}, prefix="/proxy/%s"%port, io_loop=loop, port=port, allow_websocket_origin=['localhost:%d'%port, origin, self.request.host])</code></p>
  
  <p>This doesn't work because the proxy strips the <code>/proxy/&lt;port&gt;</code> prefix before it reaches bokeh server so this isn't passed to bokeh server and bokeh server gives a 404 as it expects this prefix for all it's paths.</p>
  
  <p>Any solutions? </p>