# HACK: All WSGI apps go though the virtualenv, but we'll probably only have
# the one anyway.
WSGIPythonHome /home/vagrant/kuma-venv

WSGISocketPrefix /var/run/wsgi

#<VirtualHost *:443 *:80>
<VirtualHost *:80>

    # Covering all pre-bug-702988 past-known server aliases
    ServerName developer-kumadev.mozilla.org
    ServerAlias developer-mdndev.mozilla.org
    ServerAlias developer-dev.mozilla.org

    DirectoryIndex index.php index.html
    Options -Indexes
    
    RewriteEngine On

    DocumentRoot /var/www/dekiwiki

    <Directory /var/www/dekiwiki>
        Options +FollowSymLinks
        AllowOverride all
        Order allow,deny
        Allow from all
    </Directory>

    <Directory "/vagrant/webroot">
        # Possible values for the Options directive are "None", "All",
        # or any combination of:
        #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
        #
        # Note that "MultiViews" must be named *explicitly* --- "Options All"
        # doesn't give it to you.
        #
        # The Options directive is both complicated and important.  Please see
        # http://httpd.apache.org/docs-2.2/mod/core.html#options
        # for more information.
        Options All
        # AllowOverride controls what directives may be placed in .htaccess files.
        # It can be "All", "None", or any combination of the keywords:
        #   Options FileInfo AuthConfig Limit
        AllowOverride All
        # Controls who can get stuff from this server.
        Order allow,deny
        Allow from all
    </Directory>

    Alias /forums /var/www/forums
    Alias /media/ "/vagrant/media/"
    Alias /uploads/ "/home/vagrant/uploads/"
    Alias /admin-media/ "/vagrant/vendor/src/django/django/contrib/admin/media/"

    # This runs the python app through mod_wsgi
    # More like prod, but requires a `touch /vagrant/wsgi/*` to refresh code
    #WSGIDaemonProcess kuma processes=8 threads=1 maximum-requests=8 user=vagrant group=vagrant
    #WSGIProcessGroup kuma
    #WSGIScriptAlias /mwsgi "/vagrant/wsgi/kuma.wsgi"

    # This runs the python app from port 8000, which must be started manually
    # eg. /home/vagrant/kuma-venv/bin/python /vagrant/manage.py runserver 0.0.0.0:8000
    ProxyPass /mwsgi http://localhost:8000 retry=1
    ProxyPassReverse /mwsgi http://localhost:8000

    # deki-api uses encoded slashes in query parameters so AllowEncodedSlashes must be On
	AllowEncodedSlashes On   
       # FIXME:
       # Some php flags we need. These are only needed until all
    # the short php open tags are changed to long in the source code.
       php_flag short_open_tag on

       # Setting php memory parameters
       php_value memory_limit "128M"
    php_value post_max_size "64M"
    php_value upload_max_filesize "64M"

       # mod_proxy rules
       ProxyPass /@api http://localhost:8081 retry=1
       ProxyPassReverse /@api http://localhost:8081

	SetEnv force-proxy-request-1.0 1
	SetEnv proxy-nokeepalive 1

    <Proxy *>
        AddDefaultCharset off
        Order deny,allow
        Deny from all
        Allow from all
    </Proxy>

    # Proxy any requests for non-existent resources under /media/uploads to the
    # production site. That way, we don't need an export of files from prod for
    # references in a DB export from prod.
    #
    # FIXME: This is broken right now, because production forbids any referers
    # not from production for media assets. A referer-blocker addon might work
    SSLProxyEngine on
    RewriteCond /vagrant%{REQUEST_FILENAME} !-f
    RewriteCond /vagrant%{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} /media/uploads/
    RewriteRule ^/media/uploads/(.*)$ https://developer.mozilla.org/media/uploads/$1 [P,L]

</VirtualHost>
