elrodo1 / pywebdav

Automatically exported from code.google.com/p/pywebdav
0 stars 0 forks source link

Absolute prefix in propfind href results in wrong URIs when used behind a proxy (in DAV/propfind.py) #42

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I have setup Nginx to map port 443 of a host to an internal server:

server {
  listen       443;
  server_name  external.example.com;

  location / {
      proxy_pass_header Server;
      proxy_set_header  Host $http_host;
      proxy_set_header  X-Forwarded-For $remote_addr;
      proxy_pass        http://192.168.1.6:8008;
  }
}

On this host I run davserser like this:

# sudo -u user davserver -H 192.168.1.6 -u user -p password -D /home/user 
--verbose
INFO:pywebdav:Starting up PyWebDAV server (version 0.9.4-dev)
INFO:pywebdav:chunked_http_response feature ON
INFO:pywebdav:http_request_use_iterator feature OFF
INFO:pywebdav:http_response_use_iterator feature OFF
INFO:DAVServer.fshandler:Initialized with /home/user-http://192.168.1.6:8008/
INFO:pywebdav:Serving data from /home/user
Listening on 192.168.1.6 (8008)
INFO:root:Successfully authenticated user user
INFO:DAV.propfind:PROPFIND: Depth is 1, URI is http://external.example.com/
INFO:DAVServer.fshandler:get_childs: Childs ['http://192.168.1.6:8008/foo', 
'http://192.168.1.6:8008/bar']

However, as you can see from the verbose output of "get_childs" already: it 
uses the internal address for the listing and therefore all the links do not 
work.

Even when it would use the URI which is mentioned for 
"INFO:DAV.propfind:PROPFIND" this won't work properly: it is using "http" for 
the protocol instead of "https".

I am not sure about how to solve this: either relative links should get used or 
somehow the external base URI needs to be configured.

I have taken the relative URI approach now, by changing the following in 
mk_prop_response and mk_propname_response (DAV/propfind.py):

    huri=doc.createTextNode(uparts[0]+'://'+'/'.join(uparts[1:2]) + urllib.quote(fileloc))
to
    huri=doc.createTextNode(urllib.quote(fileloc))

This must have regressed somehow, since it worked before, but now failed when 
I've started using it again (and upgraded to 0.9.4).

Original issue reported on code.google.com by dhahler@gmail.com on 17 Nov 2010 at 10:33

GoogleCodeExporter commented 8 years ago
Thanks for your report - will be fixed in next release (new parameter -B)

Original comment by spamsch@gmail.com on 17 Feb 2011 at 12:43