I'm having a pretty torrid time with this because we've had to implement active directory authentication for Apache.  It works and users can log in with their AD accounts and that is all fine.  The problems arise when I try and get UCSC to pick up a BAM file.  The first problem is that although the Galaxy server is configured to for UCSC as a display server, putting the following into the Apache conf as recommended here http://wiki.galaxyproject.org/Admin/Config/Apache%20Proxy doesn't work.

   1 <Location "/root/display_as">
   2     Satisfy Any
   3     Order deny,allow
   4     Deny from all
   5     Allow from hgw1.cse.ucsc.edu
   6     Allow from hgw2.cse.ucsc.edu
   7     Allow from hgw3.cse.ucsc.edu
   8     Allow from hgw4.cse.ucsc.edu
   9     Allow from hgw5.cse.ucsc.edu
  10     Allow from hgw6.cse.ucsc.edu
  11     Allow from hgw7.cse.ucsc.edu
  12     Allow from hgw8.cse.ucsc.edu
  13 </Location>

All that happens is you get 401 Authorization Required errors indicating that the Apache server isn't letting the UCSC servers non-authenticated access.  Now, if I add the Allow from hgw etc into the <Location "/"> block then it gets through and then I hit the next problem which is that although I've mapped some read data against dm3 I'm getting failures inside Galaxy itself related to serving the bai file UCSC is requesting.  Here's the galaxy_access log:

192.168.240.21 - shane [23/May/2013:15:22:24 +1200] "GET /display_application/d3a4d6a5256f2d9a/ucsc_bam/main HTTP/1.1" 302 406
hgw4.cse.ucsc.edu - - [23/May/2013:15:22:24 +1200] "GET /dataset/display_application?app_action=param&user_id=207edd50b8d72f8b&app_name=ucsc_bam&action_param=track&link_name=main&dataset_id=d3a4d6a5256f2d9a HTTP/1.0" 200 311
hgw4.cse.ucsc.edu - - [23/May/2013:15:22:29 +1200] "HEAD /dataset/display_application?app_action=data&user_id=207edd50b8d72f8b&app_name=ucsc_bam&action_param=galaxy_d3a4d6a5256f2d9a.bam&link_name=main&dataset_id=d3a4d6a5256f2d9a HTTP/1.0" 200 -
hgw4.cse.ucsc.edu - - [23/May/2013:15:22:31 +1200] "HEAD /dataset/display_application?app_action=data&user_id=207edd50b8d72f8b&app_name=ucsc_bam&action_param=galaxy_d3a4d6a5256f2d9a.bam&link_name=main&dataset_id=d3a4d6a5256f2d9a.bai HTTP/1.0" 500 -
hgw4.cse.ucsc.edu - - [23/May/2013:15:22:30 +1200] "GET /dataset/display_application?app_action=data&user_id=207edd50b8d72f8b&app_name=ucsc_bam&action_param=galaxy_d3a4d6a5256f2d9a.bam&link_name=main&dataset_id=d3a4d6a5256f2d9a HTTP/1.0" 200 472000

Note the 500 when requesting the bai file.

This is what my manager.log is showing when this happens.

128.114.119.134 - - [23/May/2013:15:22:29 +1300] "HEAD /dataset/display_application?app_action=data&user_id=207edd50b8d72f8b&app_name=ucsc_bam&action_param=galaxy_d3a4d6a5256f2d9a.bam&link_name=main&dataset_id=d3a4d6a5256f2d9a HTTP/1.1" 200 3301004 "-" "genome.ucsc.edu/net.c"
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 60484)
Traceback (most recent call last):
  File "/home/galaxy/galaxy-dist/eggs/Paste-1.7.5.1-py2.6.egg/paste/httpserver.py", line 1068, in process_request_in_thread
    self.finish_request(request, client_address)
  File "/usr/lib64/python2.6/SocketServer.py", line 322, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib64/python2.6/SocketServer.py", line 618, in __init__
    self.finish()
  File "/usr/lib64/python2.6/SocketServer.py", line 661, in finish
    self.wfile.flush()
  File "/usr/lib64/python2.6/socket.py", line 303, in flush
    self._sock.sendall(buffer(data, write_offset, buffer_size))
error: [Errno 32] Broken pipe
----------------------------------------
128.114.119.134 - - [23/May/2013:15:22:30 +1300] "GET /dataset/display_application?app_action=data&user_id=207edd50b8d72f8b&app_name=ucsc_bam&action_param=galaxy_d3a4d6a5256f2d9a.bam&link_name=main&dataset_id=d3a4d6a5256f2d9a HTTP/1.1" 200 3301004 "-" "genome.ucsc.edu/net.c"
128.114.119.134 - - [23/May/2013:15:22:31 +1300] "HEAD /dataset/display_application?app_action=data&user_id=207edd50b8d72f8b&app_name=ucsc_bam&action_param=galaxy_d3a4d6a5256f2d9a.bam&link_name=main&dataset_id=d3a4d6a5256f2d9a.bai HTTP/1.1" 500 - "-" "genome.ucsc.edu/net.c"
Error - <type 'exceptions.TypeError'>: Non-hexadecimal digit found
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 60486)
Traceback (most recent call last):
  File "/home/galaxy/galaxy-dist/eggs/Paste-1.7.5.1-py2.6.egg/paste/httpserver.py", line 1068, in process_request_in_thread
    self.finish_request(request, client_address)
  File "/usr/lib64/python2.6/SocketServer.py", line 322, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib64/python2.6/SocketServer.py", line 618, in __init__
    self.finish()
  File "/usr/lib64/python2.6/SocketServer.py", line 661, in finish
    self.wfile.flush()
  File "/usr/lib64/python2.6/socket.py", line 303, in flush
    self._sock.sendall(buffer(data, write_offset, buffer_size))
error: [Errno 32] Broken pipe
----------------------------------------
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 60485)
Traceback (most recent call last):
  File "/home/galaxy/galaxy-dist/eggs/Paste-1.7.5.1-py2.6.egg/paste/httpserver.py", line 1068, in process_request_in_thread
    self.finish_request(request, client_address)
  File "/usr/lib64/python2.6/SocketServer.py", line 322, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib64/python2.6/SocketServer.py", line 618, in __init__
    self.finish()
  File "/usr/lib64/python2.6/SocketServer.py", line 661, in finish
    self.wfile.flush()
  File "/usr/lib64/python2.6/socket.py", line 303, in flush
    self._sock.sendall(buffer(data, write_offset, buffer_size))
error: [Errno 32] Broken pipe
----------------------------------------

And here's the text version in the browser (edited out our server's hostname though):

URL: https://<ourgalaxyserver>/dataset/display_application?app_action=data&user_id=207edd50b8d72f8b&app_name=ucsc_bam&action_param=galaxy_d3a4d6a5256f2d9a.bam&link_name=main&dataset_id=d3a4d6a5256f2d9a.bai
File '/home/galaxy/galaxy-dist/lib/galaxy/web/framework/middleware/error.py', line 149 in __call__
  app_iter = self.application(environ, sr_checker)
File '/home/galaxy/galaxy-dist/eggs/Paste-1.7.5.1-py2.6.egg/paste/recursive.py', line 84 in __call__
  return self.application(environ, start_response)
File '/home/galaxy/galaxy-dist/lib/galaxy/web/framework/middleware/remoteuser.py', line 91 in __call__
  return self.app( environ, start_response )
File '/home/galaxy/galaxy-dist/eggs/Paste-1.7.5.1-py2.6.egg/paste/httpexceptions.py', line 633 in __call__
  return self.application(environ, start_response)
File '/home/galaxy/galaxy-dist/lib/galaxy/web/framework/base.py', line 125 in __call__
  return self.handle_request( environ, start_response )
File '/home/galaxy/galaxy-dist/lib/galaxy/web/framework/base.py', line 182 in handle_request
  body = method( trans, **kwargs )
File '/home/galaxy/galaxy-dist/lib/galaxy/webapps/galaxy/controllers/dataset.py', line 727 in display_application
  data, user = decode_dataset_user( trans, dataset_id, user_id )
File '/home/galaxy/galaxy-dist/lib/galaxy/datatypes/display_applications/util.py', line 22 in decode_dataset_user
  dataset_id = trans.security.decode_id( dataset_hash )
File '/home/galaxy/galaxy-dist/lib/galaxy/web/security/__init__.py', line 60 in decode_id
  return int( self.id_cipher.decrypt( obj_id.decode( 'hex' ) ).lstrip( "!" ) )
File '/home/galaxy/galaxy_env/lib64/python2.6/encodings/hex_codec.py', line 42 in hex_decode
  output = binascii.a2b_hex(input)
TypeError: Non-hexadecimal digit found

I've been banging my head against this all day :-(

Shane Sturrock