Changes between Version 6 and Version 7 of TracModWSGI
- Timestamp:
- Sep 13, 2020, 5:05:14 PM (2 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TracModWSGI
v6 v7 7 7 == The `trac.wsgi` script 8 8 9 Trac can be run on top of mod_wsgi with the help of an application script, which is a Python file saved with a `.wsgi` extension. 9 Trac can be run on top of mod_wsgi with the help of an application script, which is a Python file saved with a `.wsgi` extension. 10 10 11 11 A robust and generic version of this file can be created using the `trac-admin <env> deploy <dir>` command which automatically substitutes the required paths, see TracInstall#cgi-bin. The script should be sufficient for most installations and users not wanting more information can proceed to [#Mappingrequeststothescript configuring Apache]. … … 15 15 def application(environ, start_request): 16 16 # Add this when you have multiple projects 17 environ.setdefault('trac.env_parent_dir', '/usr/share/trac/projects') 17 environ.setdefault('trac.env_parent_dir', '/usr/share/trac/projects') 18 18 .. 19 19 }}} … … 49 49 === A more elaborate script 50 50 51 If you are using multiple `.wsgi` files (for example one per Trac environment) you must ''not'' use `os.environ['TRAC_ENV']` to set the path to the Trac environment. Using this method may lead to Trac delivering the content of another Trac environment, as the variable may be filled with the path of a previously viewed Trac environment. 51 If you are using multiple `.wsgi` files (for example one per Trac environment) you must ''not'' use `os.environ['TRAC_ENV']` to set the path to the Trac environment. Using this method may lead to Trac delivering the content of another Trac environment, as the variable may be filled with the path of a previously viewed Trac environment. 52 52 53 53 To solve this problem, use the following `.wsgi` file instead: … … 59 59 import trac.web.main 60 60 def application(environ, start_response): 61 environ['trac.env_path'] = '/usr/local/trac/mysite' 61 environ['trac.env_path'] = '/usr/local/trac/mysite' 62 62 return trac.web.main.dispatch_request(environ, start_response) 63 63 }}} 64 64 65 For clarity, you should give this file a `.wsgi` extension. You should probably put the file in its own directory, since you will expose it to Apache. 65 For clarity, you should give this file a `.wsgi` extension. You should probably put the file in its own directory, since you will expose it to Apache. 66 66 67 67 If you have installed Trac and Python eggs in a path different from the standard one, you should add that path by adding the following code at the top of the wsgi script: … … 130 130 == Configuring Authentication 131 131 132 The following sections describe different methods for setting up authentication. See also [http ://httpd.apache.org/docs/2.4/howto/auth.html Authentication, Authorization and Access Control] in the Apache guide.132 The following sections describe different methods for setting up authentication. See also [https://httpd.apache.org/docs/2.4/howto/auth.html Authentication, Authorization and Access Control] in the Apache guide. 133 133 134 134 === Using Basic Authentication … … 208 208 See also the [https://httpd.apache.org/docs/2.4/mod/mod_auth_basic.html mod_auth_digest] documentation. 209 209 210 === Using LDAP Authentication 210 === Using LDAP Authentication 211 211 212 212 Configuration for [https://httpd.apache.org/docs/2.4/mod/mod_ldap.html mod_ldap] authentication in Apache is more involved (httpd 2.2+ and OpenLDAP: slapd 2.3.19). … … 268 268 269 269 See also: 270 - [https://httpd.apache.org/docs/2.4/mod/mod_authnz_ldap.html mod_authnz_ldap], documentation for mod_authnz_ldap. 270 - [https://httpd.apache.org/docs/2.4/mod/mod_authnz_ldap.html mod_authnz_ldap], documentation for mod_authnz_ldap. 271 271 - [https://httpd.apache.org/docs/2.4/mod/mod_ldap.html mod_ldap], documentation for mod_ldap, which provides connection pooling and a shared cache. 272 272 - [https://trac-hacks.org/wiki/LdapPlugin TracHacks:LdapPlugin] for storing TracPermissions in LDAP. … … 274 274 === Using SSPI Authentication 275 275 276 If you are using Apache on Windows, you can use mod_auth_sspi to provide single-sign-on. Download the module from the !SourceForge [http ://sourceforge.net/projects/mod-auth-sspi/ mod-auth-sspi project] and then add the following to your !VirtualHost:276 If you are using Apache on Windows, you can use mod_auth_sspi to provide single-sign-on. Download the module from the !SourceForge [https://sourceforge.net/projects/mod-auth-sspi/ mod-auth-sspi project] and then add the following to your !VirtualHost: 277 277 {{{#!apache 278 278 <Location /trac/login> … … 310 310 311 311 {{{#!python 312 def application(environ, start_request): 313 # Set authenticated username on CA SiteMinder to REMOTE_USER variable 312 def application(environ, start_request): 313 # Set authenticated username on CA SiteMinder to REMOTE_USER variable 314 314 # strip() is used to remove any spaces on the end of the string 315 if 'HTTP_SM_USER' in environ: 315 if 'HTTP_SM_USER' in environ: 316 316 environ['REMOTE_USER'] = environ['HTTP_REMOTE_USER'].strip() 317 317 ... … … 369 369 Please use either version 1.6, 2.4 or later of `mod_wsgi`. Versions prior to 2.4 in the 2.X branch have problems with some Apache configurations that use WSGI file wrapper extension. This extension is used in Trac to serve up attachments and static media files such as style sheets. If you are affected by this problem, attachments will appear to be empty and formatting of HTML pages will appear not to work due to style sheet files not loading properly. Another frequent symptom is that binary attachment downloads are truncated. See mod_wsgi tickets [https://code.google.com/archive/p/modwsgi/issues/100 #100] and [https://code.google.com/archive/p/modwsgi/issues/132 #132]. 370 370 371 '''Note''': using mod_wsgi 2.5 and Python 2.6.1 gave an Internal Server Error on my system (Apache 2.2.11 and Trac 0.11.2.1). Upgrading to Python 2.6.2 (as suggested [http ://www.mail-archive.com/modwsgi@googlegroups.com/msg01917.html here]) solved this for me[[BR]]-- Graham Shanks371 '''Note''': using mod_wsgi 2.5 and Python 2.6.1 gave an Internal Server Error on my system (Apache 2.2.11 and Trac 0.11.2.1). Upgrading to Python 2.6.2 (as suggested [https://www.mail-archive.com/modwsgi@googlegroups.com/msg01917.html here]) solved this for me[[BR]]-- Graham Shanks 372 372 373 373 If you plan to use `mod_wsgi` in embedded mode on Windows or with the MPM worker on Linux, then you will need version 3.4 or greater. See [trac:#10675] for details.