하나의 서버에 여러 개의 장고 앱을 호스팅하고 있습니다.
때 사용자가 방문 : 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
파일의 정적 위치에 대한 루트 경로를 작성합니다.
사용자가 I이 서비스를 제공 할 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