【发布时间】:2014-07-21 02:49:24
【问题描述】:
我想要两个在一台服务器上托管两个具有不同域的不同 django-cms 应用程序,该服务器具有运行 nginx 的相同 IP 地址。
我已经找到了这个相关的问题,但是我无法将解决方案翻译到我的 python 应用程序:Nginx Different Domains on Same IP
我已经在端口 7000 上使用 uwsgi 运行第一个 django-cms 应用程序,并通过 nginx 提供服务。
现在我想添加第二个 django-cms 应用程序,也使用端口 9000 上的 uwsgi 用于与我当前的 nginx 配置不同的域。
我尝试将第二个 uwsgi 应用程序添加到 nginx 的上游 app_servers 部分,但这不起作用并导致错误。
这是我当前的 nginx 配置:
worker_processes 1;
events {
worker_connections 1024;
}
http {
types_hash_max_size 2048;
include /etc/nginx/mime.types;
sendfile on;
gzip on;
gzip_http_version 1.0;
gzip_proxied any;
gzip_min_length 500;
gzip_disable "MSIE [1-6]\.";
gzip_types text/plain text/xml text/css
text/comma-separated-values
text/javascript
application/x-javascript
application/atom+xml;
# Configuration containing list of application servers
upstream app_servers {
server 127.0.0.1:7000;
#server 127.0.0.1:9000;
# ..
# .
}
# Configuration for Nginx
server {
# Running port
listen 80;
server_name www.myfirstdomain.at;
# Settings to serve static files
location ^~ /static/ {
# Example:
# root /full/path/to/application/static/file/dir;
alias /webapps/first-django-cms-app/static/;
}
# Serve a static file (ex. favico)
# outside /static directory
location = /favico.ico {
root /app/favico.ico;
}
# Proxy connections to the application servers
# app_servers
location / {
include /etc/nginx/mime.types;
proxy_pass http://app_servers;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
}
}
}
如何更改我的 nginx 配置以实现这一点?
【问题讨论】:
标签: python django nginx dns django-cms