0

私は開発者であり、Apacheの初心者であり、Djangohttpsサーバーの束を以前はmod_pythonを使用していたmod_wsgiに移行しようとしています。

<VirtualHost *:443>
    ServerName *.example.com

    SSLEngine On

    SSLCertificateFile /etc/ssl/star_example_com.crt
    SSLCertificateKeyFile /etc/ssl/star_example_com.key
    SSLCertificateChainFile /etc/ssl/DigiCertCA.crt

    UseCanonicalName Off
    VirtualDocumentRoot /var/www/%0

    <Directory "/var/www/foo.example.com">
        SetHandler python-program
        PythonHandler django.core.handlers.modpython
        SetEnv DJANGO_SETTINGS_MODULE example.foo.settings
        PythonPath "['/home/django'] + sys.path"
        PythonDebug on
    </Directory>

    <Directory "/var/www/bar.example.com">
        SetHandler python-program
        PythonHandler django.core.handlers.modpython
        SetEnv DJANGO_SETTINGS_MODULE example.bar.settings
        PythonPath "['/home/django'] + sys.path"
        PythonDebug on
    </Directory>
</VirtualHost>

これにより、同じ物理サーバー(IP)で複数のhttpsサイトを実行できます。新しいhttpsホストを追加するには、新しい<Directory>セクションを追加し、に対応するディレクトリを作成するだけ/var/www/です。

私が得た最も近いものは

<Directory "/var/www/bar.example.com">
    SetHandler wsgi-script
    Options ExecCGI
</Directory>

作成する/var/www/bar.example.com/bar.wsgiと、次のようなURLにアクセスできますhttps://bar.example.com/bar.wsgi/...rest..of..path..

https以外のサイトで使用しているように、ターゲットがファイルパス<Directory>の場合と同等のディレクティブ(内部で使用できる)を見つけることができませんでした。WSGIScriptAlias

<VirtualHost *:80>
    ServerName bar.example.com
    WSGIScriptAlias / /home/venv/upgrade/example/bar/bar.wsgi
    <Directory "/var/www/bar/">
        Order deny,allow
        allow from all
    </Directory>
</VirtualHost>

これにより、に移動できますhttp://bar.example.com/...rest..of..path..(つまり、bar.wsgiプレフィックスなし)。

bar.wsgihttpsのURLの部分を取り除くことは可能ですか?

[解決策:](@ GrahamDumpletonのリンクに基づく):

<Directory /var/www/bar.example.com/>
    Options ExecCGI Indexes FollowSymlinks
    AddHandler wsgi-script .wsgi
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ /bar.wsgi/$1 [QSA,PT,L]

    Order allow,deny
    Allow from all
</Directory>

美しく動作します。

4

1 に答える 1

2

これは以下でカバーされています:

http://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines#The_Apache_Alias_Directive

SCRIPT_NAMEの修正を行うためのmod_rewriteとアプリケーションラッパーの使用を示すセクションの終わりにあるビットを参照してください。

于 2012-09-07T02:06:17.173 に答える