Skip to content
Snippets Groups Projects
  • Kien Nguyen's avatar
    04394311
    Use <project>_install_type instead of kolla_install_type · 04394311
    Kien Nguyen authored
    Use <project>_install_type instead of kolla_install_type
    to set python_path. For example, general kolla_install_type
    is 'binary', but user wants to deploy Horizon from 'source'.
    Horizon templates still use python_path=/usr/share/openstack-dashboard,
    it is wrong.
    
    Change-Id: Ide6a24e17b1f8ab6506aa5e53f70693706830418
    04394311
    History
    Use <project>_install_type instead of kolla_install_type
    Kien Nguyen authored
    Use <project>_install_type instead of kolla_install_type
    to set python_path. For example, general kolla_install_type
    is 'binary', but user wants to deploy Horizon from 'source'.
    Horizon templates still use python_path=/usr/share/openstack-dashboard,
    it is wrong.
    
    Change-Id: Ide6a24e17b1f8ab6506aa5e53f70693706830418
horizon.conf.j2 3.26 KiB
{% set python_path = '/usr/share/openstack-dashboard' if horizon_install_type == 'binary' else '/var/lib/kolla/venv/lib/python2.7/site-packages' %}
Listen {{ api_interface_address }}:{{ horizon_port }}

ServerSignature Off
ServerTokens Prod
TraceEnable off

<VirtualHost *:{{ horizon_port }}>
    LogLevel warn
    ErrorLog /var/log/kolla/horizon/horizon.log
    LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b %D \"%{Referer}i\" \"%{User-Agent}i\"" logformat
    CustomLog /var/log/kolla/horizon/horizon-access.log logformat

    WSGIScriptReloading On
    WSGIDaemonProcess horizon-http processes={{ openstack_service_workers }} threads=1 user=horizon group=horizon display-name=%{GROUP} python-path={{ python_path }}
    WSGIProcessGroup horizon-http
    WSGIScriptAlias / {{ python_path }}/openstack_dashboard/wsgi/django.wsgi
    WSGIPassAuthorization On
    WSGIApplicationGroup %{GLOBAL}

    <Location "/">
        Require all granted
    </Location>

{% if kolla_base_distro == 'ubuntu' and horizon_install_type == 'binary' %}
    Alias /static /var/lib/openstack-dashboard/static
{% else %}
    Alias /static {{ python_path }}/static
{% endif %}
    <Location "/static">
        SetHandler None
    </Location>
</VirtualHost>

{% if kolla_enable_tls_external | bool %}
Header edit Location ^http://(.*)$ https://$1
{% else %}
# NOTE(Jeffrey4l): Only enable deflate when tls is disabled until the
# OSSN-0037 is fixed.
# see https://wiki.openstack.org/wiki/OSSN/OSSN-0037 for more information.
<IfModule mod_deflate.c>
    # Compress HTML, CSS, JavaScript, Text, XML and fonts
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
    AddOutputFilterByType DEFLATE application/x-font
    AddOutputFilterByType DEFLATE application/x-font-opentype
    AddOutputFilterByType DEFLATE application/x-font-otf
    AddOutputFilterByType DEFLATE application/x-font-truetype
    AddOutputFilterByType DEFLATE application/x-font-ttf
    AddOutputFilterByType DEFLATE application/x-javascript
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE font/opentype
    AddOutputFilterByType DEFLATE font/otf
    AddOutputFilterByType DEFLATE font/ttf
    AddOutputFilterByType DEFLATE image/svg+xml
    AddOutputFilterByType DEFLATE image/x-icon
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/javascript
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/xml
</IfModule>
{% endif %}

<IfModule mod_expires.c>
    <Filesmatch "\.(jpg|jpeg|png|gif|js|css|swf|ico|woff)$">
        ExpiresActive on
        ExpiresDefault "access plus 1 month"
        ExpiresByType application/javascript "access plus 1 year"
        ExpiresByType text/css "access plus 1 year"
        ExpiresByType image/x-ico "access plus 1 year"
        ExpiresByType image/jpg "access plus 1 year"
        ExpiresByType image/jpeg "access plus 1 year"
        ExpiresByType image/gif "access plus 1 year"
        ExpiresByType image/png "access plus 1 year"
        Header merge Cache-Control public
        Header unset ETag
    </Filesmatch>
</IfModule>