使用 mod_wsgi 和 SSL 的 Graphite Apache 子域

Apache subdomain for graphite using mod_wsgi and SSL

我在使用新子域配置 Apache 时遇到问题。

它是一个带有 apache2 和 graphite 的 ubuntu 服务器,我有 graphite 在端口 80 上工作(通过 apt-get 安装)

现在 apache 服务器当前服务于一个网站(https://subdomain1.domain.com) and I would like to set up apache to serve the graphite app on https://subdomain2.domain.com(端口 443)。这样 subdomain1 就可以从 graphite 访问图表。

这是我的apache2-graphite.conf

 <VirtualHost *:80>

    WSGIDaemonProcess _graphite processes=5 threads=5 display-name='%{GROUP}' inactivity-timeout=120 user=_graphite group=_graphite
    WSGIProcessGroup _graphite
    WSGIImportScript /usr/share/graphite-web/graphite.wsgi process-group=_graphite application-group=%{GLOBAL}
    WSGIScriptAlias / /usr/share/graphite-web/graphite.wsgi

    Alias /content/ /usr/share/graphite-web/static/
    <Location "/content/">
            SetHandler None
    </Location>

    ErrorLog ${APACHE_LOG_DIR}/graphite-web_error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/graphite-web_access.log combined

</VirtualHost>

和 /usr/share/graphite-web/graphite.wsgi :

import os, sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'graphite.settings'

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()

from graphite.logger import log
log.info("graphite.wsgi - pid %d - reloading search index" % os.getpid())
import graphite.metrics.search

我已经尝试更改端口并设置 ServerName 和 ServerAlias,并启用 SSL,但我无法正常工作。

示例(不工作):

<IfModule mod_ssl.c>

<VirtualHost *:443>


        ServerName graphite.<my_domain_here>    

        WSGIDaemonProcess _graphite processes=5 threads=5 display-name='%{GROUP}' inactivity-timeout=120 user=_graphite group=_graphite
        WSGIProcessGroup _graphite
        WSGIImportScript /usr/share/graphite-web/graphite.wsgi process-group=_graphite application-group=%{GLOBAL}
        WSGIScriptAlias / /usr/share/graphite-web/graphite.wsgi

        Alias /content/ /usr/share/graphite-web/static/
        <Location "/content/">
                SetHandler None
        </Location>

        ErrorLog ${APACHE_LOG_DIR}/graphite-web_error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/graphite-web_access.log combined


        SSLEngine on

        SSLCertificateFile    /etc/apache2/ssl/public.crt
        SSLCertificateKeyFile /etc/apache2/ssl/private.key
        SSLCACertificateFile /etc/apache2/ssl/ca.crt


</VirtualHost>

我发现我做错了什么:

我将子域添加到我工作站上的 /etc/hosts 并且成功了!

已向我们的虚拟主机注册子域,现在一切正常

我会把它留在这里以防它对其他人有帮助...