##################################################################################
## Copyright 2012 Dian-Je Tsai and Wantoto Inc                                  ##
##                                                                              ##
## Licensed under the Apache License, Version 2.0 (the "License");              ##
## you may not use this file except in compliance with the License.             ##
## You may obtain a copy of the License at                                      ##
##                                                                              ##
## http://www.apache.org/licenses/LICENSE-2.0                                   ##
##                                                                              ##
## Unless required by applicable law or agreed to in writing, software          ##
## distributed under the License is distributed on an "AS IS" BASIS,            ##
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.     ##
## See the License for the specific language governing permissions and          ##
## limitations under the License.                                               ##
##################################################################################
##################################################################################
##                                                                              ##
## This apache configuration file is generated by django-eggplant automatically ##
##                                                                              ##
##################################################################################

{% if serve_favicon %}Alias {{ url_prefix }}favicon.ico {{ static_path }}/favicon.ico{% endif %}
{% if serve_robots %}Alias {{ url_prefix }}robots.txt {{ static_path }}/robots.txt{% endif %}

{% if serve_static %}Alias {{ static_url }} {{ static_path }}/{% endif %}
{% if serve_media %}Alias {{ media_url }} {{ media_path }}/{% endif %}

{% if redirect_static_to_s3 and aws_s3_base_url %}
# Redirect static to S3
RewriteEngine On
RewriteRule ^{{ static_url }}/(.*)$  {{ aws_s3_base_url }}$1 [R,L]
{% endif %}

WSGISocketPrefix /var/run/wsgi
WSGIProcessGroup {{ wsgi_process_name }}
WSGIPythonOptimize {{ wsgi_python_optimize_level }}
WSGIDaemonProcess {{ wsgi_process_name }} display-name={{ wsgi_process_name }} processes={{ wsgi_processes_count }} threads={{ wsgi_threads_count }} \
    user={{ wsgi_process_user }} group={{ wsgi_process_group }} \
    python-path={{ project_source_path }}:{{ virtualenv_site_packages_path }}
WSGIScriptAlias {{ url_prefix }} {{ wsgi_script_dir_name }}/{{ wsgi_script_file_name }} process-group={{ wsgi_process_name }}

<Directory {{ wsgi_script_dir_name }}>
    <Files {{ wsgi_script_file_name }}>
        Order deny,allow
        Allow from all
    </Files>
</Directory>

{% if serve_static %}
<Directory {{ static_path }}>
    Order deny,allow
    Allow from all
</Directory>
{% endif %}

{% if serve_favicon and not serve_static %}
<Directory {{ static_path }}>
    <Files favicon.ico>
        Order deny,allow
        Allow from all
    </Files>
</Directory>
{% endif %}

{% if serve_robots and not serve_static %}
<Directory {{ static_path }}>
    <Files robots.txt>
        Order deny,allow
        Allow from all
    </Files>
</Directory>
{% endif %}

{% if serve_media %}
<Directory {{ media_path }}>
    Order deny,allow
    Allow from all
</Directory>
{% endif %}
