Home | History | Annotate | Download | only in conf
      1 #
      2 # The following prevents a system from having installed and loaded on apache
      3 # both mod_python and mod_wsgi
      4 #
      5 <IfModule mod_wsgi.c>
      6    <IfModule mod_python.c>
      7       ERROR__EITHER_MOD_WSGI_XOR_MOD_PYTHON_SHOULD_BE_ACTIVE
      8    </IfModule>
      9 </IfModule>
     10 
     11 #
     12 # Django, when running under mod_python, requires the prefork MPM, so just
     13 # fail with this bogus directive if it's not loaded. For more info see:
     14 # https://github.com/autotest/autotest/wiki/AutotestServerInstall
     15 #
     16 <IfModule !prefork.c>
     17     <IfModule mod_python.c>
     18        ERROR__DJANGO_REQUIRES_THE_PREFORK_MPM
     19     </IfModule>
     20 </IfModule>
     21 
     22 RewriteEngine On
     23 
     24 # Block all access to the django admin pages. The django admin module that we
     25 # have is known to leak memory. A simple webcrawler can get to these from our
     26 # AFE landing page and bring down cautotest by causing OOM.
     27 RewriteRule ^/admin/.* - [R=404]
     28 RewriteRule ^/afe/server/admin/.* - [R=404]
     29 RewriteRule ^/afe/server/admin - [R=404]
     30 
     31 #
     32 # Configuration for mod_wsgi
     33 #
     34 <IfModule mod_wsgi.c>
     35 
     36     RewriteCond /usr/local/autotest/frontend/frontend.wsgi -f
     37     RewriteRule ^/(afe|new_tko)/server(.*) /usr/local/autotest/frontend/frontend.wsgi [H=wsgi-script]
     38 
     39     RewriteCond /usr/lib/python2.7/site-packages/autotest/frontend/frontend.wsgi -f
     40     RewriteRule ^/(afe|new_tko)/server(.*) /usr/lib/python2.7/site-packages/autotest/frontend/frontend.wsgi [H=wsgi-script]
     41 
     42     RewriteCond /usr/lib/python2.6/site-packages/autotest/frontend/frontend.wsgi -f
     43     RewriteRule ^/(afe|new_tko)/server(.*) /usr/lib/python2.6/site-packages/autotest/frontend/frontend.wsgi [H=wsgi-script]
     44 
     45     RewriteCond /usr/lib/python2.5/site-packages/autotest/frontend/frontend.wsgi -f
     46     RewriteRule ^/(afe|new_tko)/server(.*) /usr/lib/python2.5/site-packages/autotest/frontend/frontend.wsgi [H=wsgi-script]
     47 
     48     RewriteCond /usr/lib/python2.4/site-packages/autotest/frontend/frontend.wsgi -f
     49     RewriteRule ^/(afe|new_tko)/server(.*) /usr/lib/python2.4/site-packages/autotest/frontend/frontend.wsgi [H=wsgi-script]
     50 
     51     <LocationMatch "/(afe|new_tko)/server(.*)">
     52        Options +ExecCGI
     53     </LocationMatch>
     54 
     55     WSGISocketPrefix /run/wsgi
     56     # Note: this maximum-requests argument is required because of a memory leak in the django admin pages.
     57     # The WSGIDaemonProcess directive prevents mpm_prefork from recycling the
     58     # memory that Django uses, as it is tied up in the daemon. We can prevent
     59     # the autotest memory leak from biting us by setting maximum-requests,
     60     # which will recycle each daemon process after it gets a certain number of
     61     # web requests.
     62     <IfDefine !MOBLAB_INSTANCE>
     63       # Moblab runs its own WSGI with different settings due to different memory
     64       # limitations.
     65       WSGIDaemonProcess autotestapache processes=65 threads=1 maximum-requests=200
     66     </IfDefine>
     67     WSGIProcessGroup autotestapache
     68     WSGIPassAuthorization On
     69 </IfModule>
     70 
     71 #
     72 # Configuration for mod_python
     73 #
     74 <IfModule mod_python.c>
     75     <Location ~ "/(afe|new_tko)/server">
     76         SetHandler python-program
     77         PythonHandler django.core.handlers.modpython
     78         SetEnv DJANGO_SETTINGS_MODULE frontend.settings
     79         PythonDebug On
     80         # Force our own site-packages to be loaded by mod_python prior to
     81         # mod_python's system python site-packages directory.
     82         # This way our code can depend on library versions other than
     83         # those available as packages on various OS distributions.
     84         PythonPath "['/usr/local/autotest/site-packages', '/usr/local/autotest', '/usr/lib/python2.7/site-packages/autotest', '/usr/lib/python2.6/site-packages/autotest', '/usr/lib/python2.5/site-packages/autotest', '/usr/lib/python2.4/site-packages/autotest'] + sys.path"
     85     </Location>
     86 </IfModule>
     87