{ "info": { "author": "Agendaless Consulting", "author_email": "repoze-dev@lists.repoze.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "Programming Language :: Python", "Programming Language :: Python :: 2.4", "Programming Language :: Python :: 2.5", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Internet :: WWW/HTTP :: WSGI", "Topic :: Internet :: WWW/HTTP :: WSGI :: Middleware", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "repoze.vhm README\n=================\n\n.. contents::\n\nOverview\n--------\n\nThis package provides middleware and utilities for doing virtual\nhosting within a WSGI/Repoze environment. It is particularly useful\nwithin a ``repoze.zope2`` environment, where it may be used as an\nalternative to the classic `VirtualHostMonster\n`_: method of doing\nvirtual hosting.\n\nVirtual Hosting in a Nutshell\n-----------------------------\n\n\"Virtual hosting\" enables dynamic applications to be served from\nwithin a larger URL namespace, independent of the physical location of\nthe script files used to serve the application, or the precise layout\nof objects within the application. In particular, the application and\nthe server collaborate to generate URLs for links in the application,\nsuch that the links preserve the \"apparent\" location of the\napplication.\n\nThe simplest case requires no effort at all: links rendered as\nrelative paths from within pages work nicely. However, such links\nbegin to be problematic quickly, e.g. when the page is serving as the\ndefault index view for its folder, and the URL does not end in a\n``/``. In that case, the browser interprets the links relative to the\nfolder's parent, and chaos ensues.\n\nCGI Environment Variables\n-------------------------\n\nAs used for applications running \"inside\" Apache (e.g., using\n``mod_python``), there follwing environment variables are of interest\nwhen doing virtual hosting:\n\nSERVER_NAME\n\n the name which the server believes it has.\n\nHTTP_HOST\n\n the apparent hostname of the server (i.e., as passed in the ``Host:``\n header)\n\nSERVER_PORT\n\n the apparent port of the server\n\nSCRIPT_NAME\n\n any path prefix used by Apache to dispatch to the application (as\n defined via the ``ScriptAlias`` directive).\n\nPATH_INFO\n\n the remainder of the path, after removing any parts used in\n dispatch.\n\n``repoze.vhm#vhm_xheaders`` WSGI Filter\n---------------------------------------\n\nWhen configured as WSGI middleware, this filter will convert the path\ninformation in the environment from the \"X-Vhm\" headers added to the\nrequest into the \"standard\" CGI environment variables outlined above.\nIt will also place repoze.vhm-specific environment variables into the\nWSGI environment for consumption by repoze.zope2 (or another\napplication which chooses to use its services).\n\nIf this filter is placed into the pipeline in front of a Zope 2\napplication, the standard Virtual Host Monster object\n(``/virtual_hosting``) may be deleted, as it is no longer necessary.\nHowever, it does not need to be deleted; repoze.vhm will work if it is\npresent.\n\nThe filter requires no configuration; it can be added to any pipeline\nvia its egg name: ``egg:repoze.vhm#vhm_xheaders``.\n\n``repoze.vhm#vhm_explicit`` WSGI Filter\n---------------------------------------\n\nThis filter is like the repoze.vhm#vhm_xheaders filter, but instead of taking\nthe virtual host and/or root from the environment, they are explicitly\nconfigured when the middleware is instantiated.\n\nIf using paste.deploy, this looks like::\n\n [filter:vhm]\n use = egg:repoze.vhm#vhm_explicit\n host = http://www.example.com\n root = /mysite\n\nBoth 'host' and 'root' are optional, but you probably want to specify at\nleast one of them.\n\n``repoze.vhm#vhm_path`` WSGI Filter\n-------------------------------------\n\nAs a fallback for proxies which cannot add headers to proxied\nrequests, this filter implements the same path-based virtual hosting\nsyntax used by the Zope2 Virtual Host Monster. Because this syntax is\nquite arcane (so much that there is a web-app for generating the\nrewrite rules!), this filter is not recommended except for\nenvironments which cannot be configured to add headers (e.g., Apache\nhas ``mod_rewrite`` enabled, but cannot be changed to enable\n``mod_headers``).\n\nWhen configured as WSGI middleware, this filter will convert the path\ninformation in the environment from the classic \"Zope2 virtual hosting\nmungned URL\" into the \"standard\" CGI environment variables outlined\nabove. It will also place repoze.vhm-specific environment variables\ninto the WSGI environment for consumption by repoze.zope2 (or another\napplication which chooses to use its services).\n\nIf this filter is placed into the pipeline in front of a Zope 2\napplication, the standard Virtual Host Monster object\n(``/virtual_hosting``) may be deleted, as it is no longer necessary.\nHowever, it does not need to be deleted; repoze.vhm will work if it is\npresent.\n\nThe filter requires no configuration; it can be added to any pipeline\nvia its egg name: ``egg:repoze.vhm#vhm_path``.\n\nYou can set the ``conserve_path_infos`` parameter if you want only the host and port bits to be touched.::\n\n [filter:vhm]\n use = egg:repoze.vhm#vhm_path\n conserve_path_infos = true\n\nThis trick can be useful to forward the url AS-IS to an underlying equipment wiwhtout touching to the URI. Eg, a wsgi pipeline where our repoze.vhm filters some content from a stock zope2 server which do the VHM stuff also on its own.\n\n\nExample: a deliverance middleware filtering out a stock zope2+plone server\n-----------------------------------------------------------------------------\n\nWe have in this setup a frontal apache server reverse proxyfing a deliverance server.\n\nFirst, we will tell apache to proxy our requests to our backends.\n\nApache will tell:\n\n - At the wsgi level, rewrite links using things in the request headers\n - At the zope2 level, use the URL with vhmonster to rewrite links.\n\n\n::\n\n # Rewrite links in paste\n RequestHeader add X-Vhm-Host http://host.tld:80/\n # /_themes & .deliverance -> deliverance\n ProxyPassMatch /(_themes|\\.deliverance)(.*) http://localhost:8378/$1$2\n ProxyPassReverse /_themes/ http://localhost:8378/_themes/\n ProxyPassReverse /.deliverance/ http://localhost:8378/.deliverance/\n\n # application mounted on / does not needs _vh_\n # /zmiroot -> access to zmi\n ProxyPassMatch ^/zmiroot(.*) http://localhost:8381/VirtualHostBase/http/host.tld:80/VirtualHostRoot/_vh_zmiroot$1\n ProxyPassReverse ^/zmiroot/ http://localhost:8381/VirtualHostBase/http/host.tld:80/VirtualHostRoot/_vh_zmiroot/\n\n # /plone-plonesiteid-> vhmonster without deliverance filtering\n ProxyPassMatch ^/plone-plonesiteid(.*) http://localhost:8381/VirtualHostBase/http/host.tld:80/plonesiteid/VirtualHostRoot/_vh_plone-plonesiteid$1\n ProxyPassReverse ^/plone-plonesiteid/ http://localhost:8381/VirtualHostBase/http/host.tld:80/plonesiteid/VirtualHostRoot/_vh_plone-plonesiteid/ \n\n # /-> zope2vhmonster\n ProxyPass / http://localhost:8378/VirtualHostBase/http/host.tld:80/plonesiteid/VirtualHostRoot/\n ProxyPassReverse / http://localhost:8378/VirtualHostBase/http/host.tld:80/plonesiteid/VirtualHostRoot/\n \n\nThis deliverance server is just another PasteDeploy setup which query somehow a zope2 server listening somewhere.\n::\n\n [DEFAULT]\n debug=false\n\n [app:athemes]\n use = egg:Paste#static\n document_root=%(here)s/sometheme/path\n\n [app:azopeproxy]\n use = egg:Paste#proxy\n address=http://ZOPE:8381/\n\n [filter:fdeliverance]\n use=egg:Deliverance\n theme_uri = sometheme\n rule_uri = file://somerules\n execute_pyref=true\n\n [filter:ftranslogger]\n use=egg:Paste#translogger\n setup_console_handler=true\n\n [filter:fexc]\n use=egg:WebError#evalerror\n\n [filter:fvhm]\n use = egg:repoze.vhm#vhm_xheaders\n\n [pipeline:pmain]\n pipeline = fexc\n ftranslogger\n fvhm\n fdeliverance\n azopeproxy\n\n [composite:main]\n use = egg:Paste#urlmap\n / = pmain\n /_themes = athemes\n\n [server:main]\n use=egg:Paste#http\n host = localhost\n port = 8378\n\n\nrepoze.vhm Virtual Hosting Model\n--------------------------------\n\nThis model (based on a `suggestion of Ian Bicking's ,\n`_),\npasses virtual hosting information from the proxy / web server to the\napplication by adding extra headers to the proxied request:\n\nHTTP_X_VHM_HOST\n\n indicates the apparent URL prefix of the root of the application\n (concatenating ``wsgi.url_scheme``, ``SERVER_NAME``,\n ``SERVER_PORT``, and ``SCRIPT_NAME`` variables; the equivalent of\n Zope2's ``SERVER_URL``).\n\nHTTP_X_VHM_ROOT\n\n path of the object within the application which is supposed to\n function as the \"virtual root\".\n\nWhen serving an application from \"within\" Apache via mod_wsgi, we can\njust set the environment directly::\n\n \n SetEnv HTTP_X_VHM_HOST http://www.example.com\n SetEnv HTTP_X_VHM_ROOT /cms\n \n\nIf you are serving repoze.zope2 via a proxy rewrite rule, you may pass\nthis information by adding additional headers. E.g., a sample Apache\nconfiguration for the example above might be::\n\n \n ServerName www.example.com\n RewriteEngine on\n RewriteRule ^/(.*) http://localhost:8080/$1 [P,L]\n RequestHeader add X-Vhm-Host http://www.example.com\n RequestHeader add X-Vhm-Root /cms\n \n\nIn either of the above example cases, the effect on repoze.zope2 when\nrepoze.vhm's filter is in the WSGI pipeline is the same: the apparent\nroot of ``http://www.example.com`` will be the default view of the\nobject that has a physical path of ``/cms``. Additionally, paths in\nURLs generated by Zope will not start with ``/cms``, and the scheme\nand hostname in URLs will be \"http://www.example.com\" as opposed to\n``http://localhost:8080``.\n\nThe \"vhm host\" header may contain further path information as\nnecessary; further path information can (and will, in the case of\nrepoze.zope2) be respected by downstream applications to root an\napplication at a non-server-root path ::\n\n \n SetEnv HTTP_X_VHM_HOST http://www.example.com/further/path\n SetEnv HTTP_X_VHM_ROOT /cms\n \n\nIn this case, URLs generated by Zope will begin with\n``http://www.example.com/further/path``. This syntax replaces the\n\"inside out\" virtual hosting syntax (``_vh_`` segment markers in the\nURL) as described in the \"Virtual Host Monster\" documentation.\n\nThe \"vhm host\" and \"vhm root\" headers can be used independently (the\nsystem will operate as you would expect in the absence of one or the\nother).\n\n``repoze.vhm`` Library API\n--------------------------\n\nBecause the existing Zope 2 virtual hosting machinery does not rely on\nthe \"standard\" CGI variables, the application dispatcher needs to \"fix\nup\" the environment to match Zope's expectations. ``repoze.vhm``\noffers the following functions to aid in this fixup:\n\nrepoze.vhm.utils.setServerURL\n\n convert the standard CGI virtual hosting environment into the form\n expected by Zope2 (adding the ``SERVER_URL`` key).\n\nrepoze.vhm.utils.getVirtualRoot\n\n return the virtual root path (``repoze.vhm.virtual_root``) as set\n by the middleware.\n\nrepoze.vhm Changelog\n====================\n\n0.14 (2012-03-24)\n-----------------\n\n- Ensure HTTP_HOST is set correctly for non-standard ports under VHM paths.\n This header requires a trailing port if not the default for a given service.\n See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23.\n [davidjb]\n\n0.13 (2010-04-18)\n----------------- \n- add conserve_path_infos for the VHMPathFilter middleware [kiorky]\n\n0.12 (2010-01-01)\n-----------------\n\n- Update tests of middleware to check only that ``munge`` is called correctly.\n\n- Test ``munge`` sepearately.\n\n- 100% test coverage.\n\n- fixed xheaders filter to set PATH_INFO correctly\n [vangheem]\n \n\n0.11 (2009-08-31)\n-----------------\n\n- Add a repoze.vhm#vhm_explicit filter. This is like the vhm_xheaders\n middleware, but the VHM host and/or root are set in the WSGI configuration\n instead of in the request.\n\n- Calculate a VIRTUAL_URL and put it into the environment. This is basically\n the URL that the end user sees. repoze.zope2 >= 1.0.2 uses this to compute\n the ACTUAL_URL request variable, for example.\n\n0.10 (2009-08-26)\n-----------------\n\n- Apply the HTTP_HOST port number fix to the VHM Path filter as well.\n\n0.9 (2009-07-09)\n----------------\n\n- 100% test coverage.\n\n- ``HTTP_HOST`` parameter now includes port number if not http:80 or\n https:443. Thanks to Martin Aspeli.\n\n0.8 (2009-01-10)\n----------------\n\n- Set 'HTTP_HOST' in environ to the same value as 'SERVER_NAME', FBO apps\n which need it.\n\n0.7 (2008-05-07)\n----------------\n\n- Remove 'dependency-links=' to dist.repoze.org to prevent easy_install\n from searching there inappropriately.\n\n0.6 (2008-04-17)\n----------------\n\n- Re-added the path-segment-based filter as an option, to support scenarios\n in which the reverse proxy can be configured to rewrite the URL but not\n to add headers.\n\n0.5 (2008-03-09)\n----------------\n\n- Brown bag release: I fudged the entry point for the xheaders filter.\n\n0.4 (2008-03-09)\n----------------\n\n- Kill off path-segment-based filter (repoze.vhm.zope2). Only the\n xheaders filter remains.\n\n- Add license headers.\n\n- The middleware now sets a 'repoze.vhm.virtual_host_base' which is\n preferred by setServerUrl over 'HTTP_HOST' when present.\n\n- Add a getVirtualRoot API.\n\n0.3 (2007-10-25)\n----------------\n\n- Fix setServerURL method to take into account HTTP_HOST passed by\n client.\n\n0.2 (2007-09-22)\n----------------\n\n- Change repoze.vhm.zope2:setServerURL to allow Zope 2 to generate the\n correct request['URL'] value when the vhm is in the pipeline.\n\n0.1 (2007-09-21)\n----------------\n\n- Initial release.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://www.repoze.org", "keywords": "web application server wsgi zope repoze", "license": "BSD-derived (http://www.repoze.org/LICENSE.txt)", "maintainer": null, "maintainer_email": null, "name": "repoze.vhm", "package_url": "https://pypi.org/project/repoze.vhm/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/repoze.vhm/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://www.repoze.org" }, "release_url": "https://pypi.org/project/repoze.vhm/0.14/", "requires_dist": null, "requires_python": null, "summary": "repoze virtual hosting middleware.", "version": "0.14" }, "last_serial": 804718, "releases": { "0.10": [ { "comment_text": "", "digests": { "md5": "1f920e64c0a2d70048a183dc2b3e9c1b", "sha256": "0f8ff1b12265fe6ada069eeba4cdf6b6d472af461ed73788ec6dcd6fcd52c491" }, "downloads": -1, "filename": "repoze.vhm-0.10.tar.gz", "has_sig": false, "md5_digest": "1f920e64c0a2d70048a183dc2b3e9c1b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12847, "upload_time": "2009-08-26T16:32:06", "url": "https://files.pythonhosted.org/packages/d9/4a/770c07cc89686a7912367f9f0b09c1c84deb8036c1a3f4af10bc71ea7eae/repoze.vhm-0.10.tar.gz" } ], "0.11": [ { "comment_text": "", "digests": { "md5": "d6f74e479163bee04c138aec04af95a8", "sha256": "ea3aca8b6f70a3f4da622b1b642da928bbb53f66a66a47a8c4cc423e571a5ed6" }, "downloads": -1, "filename": "repoze.vhm-0.11.tar.gz", "has_sig": false, "md5_digest": "d6f74e479163bee04c138aec04af95a8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13743, "upload_time": "2009-08-31T18:00:37", "url": "https://files.pythonhosted.org/packages/bc/a1/20b34e616b6015f48872cb8d788783898b2d5269bc1c69d991d1a814ae08/repoze.vhm-0.11.tar.gz" } ], "0.12": [ { "comment_text": "", "digests": { "md5": "88ee49fec23090679f05faaf7a73b216", "sha256": "3a3407c39559ac5eb85b0ef561b1ca70de5229c6750ec6514994843e835cc37b" }, "downloads": -1, "filename": "repoze.vhm-0.12.tar.gz", "has_sig": false, "md5_digest": "88ee49fec23090679f05faaf7a73b216", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14800, "upload_time": "2010-01-01T08:49:07", "url": "https://files.pythonhosted.org/packages/37/6e/46f8eaa27292be2d193d9fd23dccf959d17daa57a228d63de78d5249c4ca/repoze.vhm-0.12.tar.gz" } ], "0.13": [ { "comment_text": "", "digests": { "md5": "b457ee2c98bccb4efa9bba081f17114f", "sha256": "865e9dcf9c8c62e549aa547e8edfda037b4382e93b3b490744b467266bf3bc79" }, "downloads": -1, "filename": "repoze.vhm-0.13.zip", "has_sig": false, "md5_digest": "b457ee2c98bccb4efa9bba081f17114f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 25855, "upload_time": "2010-04-18T18:19:41", "url": "https://files.pythonhosted.org/packages/bc/dc/eb59230ec1b624a44eb0a39420e024ebc7041f36a87e170747710542486a/repoze.vhm-0.13.zip" } ], "0.14": [ { "comment_text": "", "digests": { "md5": "363beb4d81fe7cc0c8c42b8864f110bd", "sha256": "2b76ac63dac4fa5c707222cf5d75dbaefc6b53861405424ac79d2cdb7c7c1532" }, "downloads": -1, "filename": "repoze.vhm-0.14.tar.gz", "has_sig": false, "md5_digest": "363beb4d81fe7cc0c8c42b8864f110bd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21368, "upload_time": "2012-03-25T01:54:26", "url": "https://files.pythonhosted.org/packages/76/df/0175302b40198e77ad213562ce41f1d8a8ddcd537296c44ef2fa352bc9d8/repoze.vhm-0.14.tar.gz" } ], "0.9": [ { "comment_text": "", "digests": { "md5": "293c06ee633219dd7008273e97d40f21", "sha256": "a899157db65aeab5a64bc355c4b61a60527ca5ad53b3a5f4e4f7dec6c9d3bf77" }, "downloads": -1, "filename": "repoze.vhm-0.9.tar.gz", "has_sig": false, "md5_digest": "293c06ee633219dd7008273e97d40f21", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12499, "upload_time": "2009-08-09T19:01:04", "url": "https://files.pythonhosted.org/packages/9e/9f/8e048c7936946db59064e9c880916e7b66a004c8e9e987ac990726e7c07f/repoze.vhm-0.9.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "363beb4d81fe7cc0c8c42b8864f110bd", "sha256": "2b76ac63dac4fa5c707222cf5d75dbaefc6b53861405424ac79d2cdb7c7c1532" }, "downloads": -1, "filename": "repoze.vhm-0.14.tar.gz", "has_sig": false, "md5_digest": "363beb4d81fe7cc0c8c42b8864f110bd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21368, "upload_time": "2012-03-25T01:54:26", "url": "https://files.pythonhosted.org/packages/76/df/0175302b40198e77ad213562ce41f1d8a8ddcd537296c44ef2fa352bc9d8/repoze.vhm-0.14.tar.gz" } ] }