Django + uwsgi + nginx重定向到默认页面"Welcome to NGINX"; [英] Django + uwsgi + nginx redirect to default page "Welcome to NGINX"

查看:451
本文介绍了Django + uwsgi + nginx重定向到默认页面"Welcome to NGINX";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是python和Django的初学者.但是,我正在尝试创建服务器来部署我的应用程序.但是,当我想访问我的应用程序时,总是得到默认的nginx页面欢迎使用nginx".

I'm a very beginner in python and django. However I'm trying to create a server to deploy my application. But when I want to access my app, I always get the default nginx page "Welcome to nginx".

此服务器位于Ubuntu 12.04(精确)上 我已经用apt安装了nginx,python,django和uwsgi软件包. 接下来,我已经为/var/www/djangoApps创建了一个django项目,并为/var/www/djangoApps/testApp创建了一个django应用

This server is on Ubuntu 12.04 (precise) I've installed nginx, python, django and uwsgi packages with apt. Next I've created a django project to /var/www/djangoApps and a django app to /var/www/djangoApps/testApp

这是我的/etc/nginx/sites-available/djangoApps:

This is my /etc/nginx/sites-available/djangoApps :

server {
    listen 80
    server_name django.pommesky.com;
    rewrite ^(.*) http://www.django.pommesky.com/$1 permanent;
}

server {
    listen 80;
    server_name www.django.pommesky.com;
    access_log /var/log/nginx/djangoApps_access.log;
    error_log /var/log/nginx/djangoApps_error.log;

    location /media {
        alias /var/www/djangoApps/media/;
    }

    location /static {
        alias /var/www/djangoApps/static/;
    }

    location / {
        uwsgi_pass unix:///run/uwsgi/app/djangoApps/socket;
        include uwsgi_params;
    }
}

这是我的/etc/uwsgi/apps-available/djangoApps.ini:

And this is my /etc/uwsgi/apps-available/djangoApps.ini :

env = DJANGO_SETTINGS_MODULE=djangoApps.settings
module = django.core.handlers.wsgi:WSGIHandler()
chdir = /var/www/djangoApps
socket = /run/uwsgi/djangoApps/socket
logto = /var/log/uwsgi/djangoApps.log

uwsgi日志未显示任何内容,一切似乎运行良好,它由生成的uWSGI worker完成... 但是/var/log/nginx/djangoApps_access.log;和/var/log/nginx/djangoApps_error.log;不存在,这很奇怪. 我无法弄清楚我的配置出了什么问题. 请帮助我...

The uwsgi log doesn't show anything, everything seems to run well, it finishes by spawned uWSGI worker ... But /var/log/nginx/djangoApps_access.log; and /var/log/nginx/djangoApps_error.log; don't exist, which is very strange. I can't figure out what's wrong with my configuration. Please help me ...

推荐答案

django.pommesky.com似乎并不活跃,因此Nginx可能会收到 HTTP请求标头.(第14.23节),因此Nginx提供了default全面服务页面.

The domain django.pommesky.com doesn't look like it's alive, so it's possible that Nginx is receiving requests with wrong Host: field in the HTTP request header. (sect. 14.23) So Nginx serves a default catch-all page.

您可以通过删除/etc/nginx/sites-enabled/default链接,然后重新启动守护程序来禁用default Nginx站点.

You can disable the default Nginx site by removing the /etc/nginx/sites-enabled/default link, and then restarting the daemon.

sudo rm -v /etc/nginx/sites-enabled/default
sudo service nginx restart

您可以通过重新创建链接来重新启用:

You can reenable by recreating the link:

sudo ln -sf /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
sudo service nginx restart

您可以尝试的另一件事是设置Bind或另一个DNS守护程序,以为您想要的所有子域提供 fake pommesky.com区域,并在开发站点时使用该DNS.

The other thing you can try is to setup Bind or another DNS daemon to serve a fake pommesky.com zone with all the subdomains you want and use that DNS while you're developing your site.

当然,您也可以向托管服务提供商注册该域,然后使用其控制面板中的DNS区域编辑器来设置您的子域和所有

Of course you can also register that domain with a hosting provider, and then use the DNS zone editor in its control panel to setup your subdomains and all the PTRs you want to whatever public IP addresses you need.

这篇关于Django + uwsgi + nginx重定向到默认页面"Welcome to NGINX";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆