在nginx的同一ip上运行两个不同的Djangocms应用程序,这些应用程序具有不同的域

2024-04-25 23:12:22 发布

您现在位置:Python中文网/ 问答频道 /正文

我想要两个主机两个不同的django cms应用程序,在一个服务器上有相同的ip地址运行nginx。在

我已经找到了这个相关的问题,但是我不能将这个解决方案翻译成python应用程序:Nginx Different Domains on Same IP

我已经在7000端口上运行了第一个使用uwsgi的django cms应用程序,并通过nginx提供服务。在

现在,我想在我当前的nginx配置中添加第二个django cms应用程序,该应用程序也在端口9000上使用uwsgi,用于不同的域。在

我试图将第二个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配置以使其成为可能?在


Tags: djangotextapp应用程序servercmsapplicationnginx