私は1台のサーバーに複数のdjangoアプリケーションをホスティングしています。
すると、ユーザの訪問:http://dev-app.example.com/testapp1
私はアプリの間で同じ資産が、それらに同じパスを使用していないので、動的に$のURIから生成されたルート・パスと静的/奉仕する必要があります。
私のnginxの設定ファイルツリー:
nginx
├── sites-enabled
│ ├── myconf
│ myapps/
│ ├── testapp1
│ └── testapp2
MYCONFファイル:
server {
listen 8088;
server_name dev-app.example.com;
location = favicon.ico { access_log off; log_not_found off; }
location /static
# The line below isn't working even if the $uri has the string I want to concatenate
root /home/user$uri/current;
}
include /etc/nginx/myapps/*;
}
testapp1ファイル:
location /testapp1 {
include uwsgi_params;
uwsgi_pass unix:/home/user/testapp1/current/testapp1.sock;
}
testapp2ファイル:
location /testapp2 {
include uwsgi_params;
uwsgi_pass unix:/home/user/testapp2/current/testapp2.sock;
}
nginxの組み込み変数$ uriを使用して、要求されたアプリケーションごとにmyconf
ファイルに/ staticの場所のルートパスを作成します。
ユーザーが、私はこれを提供したいhttp://dev-app.example.com/whatever開き
:# In the myconf file
location /static {
root /home/user/whatever/current;
}
nginxの設定の大きな部分を表示できますか?これがどう動くべきかわかりません... – GwynBleidD
@GwynBleidD私はちょうど、ありがとう。 –
正しく理解されているかどうかを確認するだけで、あなたのアプリケーションは '//yourdomain.com/testapp1'と' // yourdomain.com/testapp2'に提供されますが、両方のアプリケーションで静的ファイルは '/yourdomain.com/static '。正しい? – GwynBleidD