Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tiles did not work with reverse proxy configured to multiple sites #59

Closed
cleberjsantos opened this issue Sep 6, 2012 · 11 comments
Closed
Assignees
Labels
Milestone

Comments

@cleberjsantos
Copy link
Member

If we're working with reverse proxy and multiple sites plone and our configuration is like the example below, have problems with viewing.

Reproduce the error.
  1. Configure an webserver eg: Nginx

        server {
            listen 80;
            server_name cleberjsantos.com.br
                        www.cleberjsantos.com.br;
    
            if ($http_host != "www.cleberjsantos.com.br"){
                rewrite ^/(.*) http://www.cleberjsantos.com.br/$1 permanent;
                break;
            }
    
            location ~ /\. {
                deny  all;
            }
    
            location / {
                rewrite ^/(.*) /VirtualHostBase/http/$server_name:80/plone/VirtualHostRoot/_vh_subplone/$1 break;
                proxy_pass http://127.0.0.1:8081;
            }
    
            location ^~ /subplone {
                rewrite ^/subplone/?(.*) /VirtualHostBase/http/$server_name:80/otherplone/VirtualHostRoot/_vh_subplone/$1 break;
                proxy_pass http://127.0.0.1:8081;
            }
    }
  2. First, go directly to the instance and add a cover, then we'll open the two Plone sites in the browser

  3. Until the second step we have no problem, now we access the Plone sites through the Nginx server.

Trace back
2012-09-06 16:17:58 ERROR plone.transformchain Unexpected error whilst trying to apply transform chain
Traceback (most recent call last):
  File "/media/bkp/buildout_cache/eggs/plone.transformchain-1.0.2-py2.6.egg/plone/transformchain/transformer.py", line 48, in __call__
    newResult = handler.transformIterable(result, encoding)
  File "/media/bkp/buildout_cache/eggs/plone.app.blocks-1.0-py2.6.egg/plone/app/blocks/transform.py", line 151, in transformIterable
    result.tree = tiles.renderTiles(self.request, result.tree)
  File "/media/bkp/buildout_cache/eggs/plone.app.blocks-1.0-py2.6.egg/plone/app/blocks/tiles.py", line 41, in renderTiles
    tileTree = utils.resolve(tileHref)
  File "/media/bkp/buildout_cache/eggs/plone.app.blocks-1.0-py2.6.egg/plone/app/blocks/utils.py", line 51, in resolve
    resolved = resolveResource(url)
  File "/media/bkp/buildout_cache/eggs/plone.app.blocks-1.0-py2.6.egg/plone/app/blocks/utils.py", line 66, in resolveResource
    raise NotFound(url)
NotFound: http://localhost:8081/otherplone/my_other_cover/@@collective.cover.basic/058e0245013b4c5a82b9ca9c7fcc66cc
@ghost ghost assigned cleberjsantos Sep 6, 2012
@hvelarde
Copy link
Member

hvelarde commented Sep 6, 2012

@frapell @Quimera could you please take a look on this issue?

@cewing
Copy link
Member

cewing commented Sep 6, 2012

Just to be aware, I know of someone here in Seattle who has seen a similar problem. Tiles in a site using vh parameters in a virtual hosting setup failing to render. The issue appears to be related to the presence of the vh stuff in the proxy URL. It appears it may be a bug in the subrequest package. I think there is an issue already open, but you might start looking there.

@hvelarde
Copy link
Member

hvelarde commented Sep 6, 2012

you mean the plone.subrequest package? could you please provide a link for the bug report, @cewing ?

@cewing
Copy link
Member

cewing commented Sep 6, 2012

@hvelarde I do mean that. I just asked, and there is no bug report open yet. But here's the line where it happens:

https://github.com/plone/plone.subrequest/blob/master/plone/subrequest/__init__.py#L73

according to my friend up here, the vh bits are not removed properly in handling vurl_parts in the lines immediately preceding that one. Drop a breakpoint there and he says you'll see the problem.

@cleberjsantos
Copy link
Member Author

I'm analyzed the problem is not in subrequest, but as we are passing the url eg:

Call subrequest(url), it returns a response object.

>>> from plone.subrequest import subrequest
>>> response = subrequest('/folder1/@@url')
>>> response.getBody()
'http://nohost/folder1'

The sample above show a basic usage, an observation in the passed url, is relative url and not absolute. View documentation here: http://pypi.python.org/pypi/plone.subrequest/

The soluction is in pull request #60 ;)

@cewing
Copy link
Member

cewing commented Sep 6, 2012

I think this just routes around the problem, which is in subrequest. vhost urls are not properly handled there if they have vh elements in them

@cleberjsantos
Copy link
Member Author

But see, in the tests are planned vhost urls , i ran these tests and passed. :-$

https://github.com/plone/plone.subrequest/blob/master/plone/subrequest/tests.py#L30

@jessesnyder
Copy link

I'm the guy who ran into similar problems with plone.subrequest when using vh. I also found the apparently thorough test suite intimidating, but I'm not convinced the relatively common way I'm using vh in my rewrite rule is actually covered by the tests. I will spend a bit of time investigating this evening.

@cewing
Copy link
Member

cewing commented Sep 8, 2012

Okay, we've resolved locally why this isn't working in the vh use case with a full site url. The issue is that a subrequest is resolved entirely through zope traversal, not through a request to Apache. Therefore, VH rewrites at the proxy level never occur, and the URL passed to the subrequest is just wrong.

The lesson we've learned here is that with tiles it might be better to think of the 'url' you are providing as the data-tile attribute more as a traversal path and less as a URL.

Sorry for clouding the issue for you all. Putting this here so there's a record of the full resolution of the issue

@cleberjsantos
Copy link
Member Author

It seems to me that problem's in the form that we pass url to subrequest, if in the data-tile we pass correct url (eg: /VirtualHostBase/http/www.cleberjsantos.com,.br:80/otherplone/VirtualHostRoot/_vh_subplone/) pass without problem, but the Plone is behind the Web server and perhaps the subrequest would have to be able to understand that.

@frapell
Copy link
Member

frapell commented Sep 10, 2012

I don't have much experience with virtual hosts and proxies, but I have just cloned your fork and everything seems to be working fine, also tests are passing ok, so, if this fixes the issue and doesn't introduce any (known) bug, i would say it's a +1 from me

jpgimenez pushed a commit that referenced this issue Apr 19, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants