nginx + uwsgi + django,如何配置404.html和502.html [英] nginx+uwsgi+django, how to configure 404.html and 502.html
本文介绍了nginx + uwsgi + django,如何配置404.html和502.html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我关闭了调试模式,当我访问一个非exsit页面时,我看到一个默认的502错误。
我已经把404.html,403.html, 502.html在我的项目中,但我仍然看不到这些页面,除了这部分之外,该项目工作得很好,我该怎么配置这个问题?
我的配置如下:
server {
listen 80;
server_name 119.254.35.221;
location / {
uwsgi_pass 127.0.0.1:8000;
包括uwsgi_params;
uwsgi_param UWSGI_SCRIPT www.wsgi;
uwsgi_param UWSGI_CHDIR / root / www;
uwsgi_param UWSGI_PYHOME / root / www;
uwsgi_param SCRIPT_NAME;
}
}
项目树:
[root @ vps616 www]#pwd
/ pre>
/ root / www
[root @ vps616 www]#ll
total 1036
drwxr-xr-x 2 root root 4096 Sep 28 11:05 books
-rwxr-xr-x 1 root root 246 Sep 27 13:29 manage.py
-rw-- ----- 1根根6228 Sep 28 09:56 nohup.out
-rwxr-xr-x 1 root root 41 Sep 27 23:54 restart.sh
-rwxr-xr-x 1 root root 53 Sep 28 16:51 start.sh
drwxr-xr-x 2 root root 4096 Sep 28 20:18 static
-rw-rw-rw- 1 root root 217 Sep 28 14:05 uwsgi.ini
-rw-r - r-- 1 root root 272 Sep 27 23:16 uwsgi.xml.backup
drwxr-xr-x 3 root root 4096 Sep 28 20:27 www
-rw-r ----- 1 root root 1009290 Sep 28 20:25 www.log
-rw-rw-rw- 1 root root 6 Sep 28 16:48 www.pid
[root @ vps616 www]#ll www
total 48
-rw-r - r-- 1 root root 0 Sep 28 20:27 403.html
-rw-r- -r-- 1 root root 0 Sep 28 20:18 404.html
-rw-r - r-- 1根根227 9月28日17:01 forms.py
-rw-r - r-- 1 root root 0 Sep 27 13:29 __init__.py
-rw-r - r-- 1根根112 9月28日08:46 __init __。pyc
-rw-r - r-- 1 root root 5247 Sep 28 20:20 settings.py
-rw-r - r-- 1根根2924 Sep 28 20:20 settings.pyc
drwxr-xr-x 2 root root 4096 Sep 28 17:04 templates
-rw-r - r-- 1 root root 630 Sep 28 16:47 urls .py
-rw-r - r-- 1 root root 641 Sep 28 11:03 urls.pyc
-rw-r - r-- 1 root root 625 Sep 28 17:22意见.py
-rw-r - r-- 1根根871 Sep 28 11:03 views.pyc
-rw-r - r-- 1根根1126 Sep 28 12:32 wsgi .py
-rw-r - r-- 1根根1000 Sep 28 12:32 wsgi.pyc
[root @ vps616 www]#
uwsgi配置:
[root @ vps616 www ]#cat uwsgi.ini
[uwsgi]
uid = 500
listen = 200
master = true
profiler = true
processes = 8
logdate = true
pidfile = /root/www/www.pid
daemonize = /root/www/www.log
enable-threa ds = true
memory-report = true
limit-as = 6048
开始命令:
uwsgi --ini uwsgi.ini -s 127.0.0.1:8000
非常感谢。
解决方案移动您的模板目录中的404.html等文件(如果您有base_site.html,则可以使用)
I close debug mode, and I see a default 502 Error when I visit a non-exsit page.
I have put 404.html, 403.html, 502.html in my project, but I still can't see these pages, the project works all well except this part, what should i config about this problem ?
My configuration below:
server{ listen 80; server_name 119.254.35.221; location /{ uwsgi_pass 127.0.0.1:8000; include uwsgi_params; uwsgi_param UWSGI_SCRIPT www.wsgi; uwsgi_param UWSGI_CHDIR /root/www; uwsgi_param UWSGI_PYHOME /root/www; uwsgi_param SCRIPT_NAME ""; } }
The project tree:
[root@vps616 www]# pwd /root/www [root@vps616 www]# ll total 1036 drwxr-xr-x 2 root root 4096 Sep 28 11:05 books -rwxr-xr-x 1 root root 246 Sep 27 13:29 manage.py -rw------- 1 root root 6228 Sep 28 09:56 nohup.out -rwxr-xr-x 1 root root 41 Sep 27 23:54 restart.sh -rwxr-xr-x 1 root root 53 Sep 28 16:51 start.sh drwxr-xr-x 2 root root 4096 Sep 28 20:18 static -rw-rw-rw- 1 root root 217 Sep 28 14:05 uwsgi.ini -rw-r--r-- 1 root root 272 Sep 27 23:16 uwsgi.xml.backup drwxr-xr-x 3 root root 4096 Sep 28 20:27 www -rw-r----- 1 root root 1009290 Sep 28 20:25 www.log -rw-rw-rw- 1 root root 6 Sep 28 16:48 www.pid [root@vps616 www]# ll www total 48 -rw-r--r-- 1 root root 0 Sep 28 20:27 403.html -rw-r--r-- 1 root root 0 Sep 28 20:18 404.html -rw-r--r-- 1 root root 227 Sep 28 17:01 forms.py -rw-r--r-- 1 root root 0 Sep 27 13:29 __init__.py -rw-r--r-- 1 root root 112 Sep 28 08:46 __init__.pyc -rw-r--r-- 1 root root 5247 Sep 28 20:20 settings.py -rw-r--r-- 1 root root 2924 Sep 28 20:20 settings.pyc drwxr-xr-x 2 root root 4096 Sep 28 17:04 templates -rw-r--r-- 1 root root 630 Sep 28 16:47 urls.py -rw-r--r-- 1 root root 641 Sep 28 11:03 urls.pyc -rw-r--r-- 1 root root 625 Sep 28 17:22 views.py -rw-r--r-- 1 root root 871 Sep 28 11:03 views.pyc -rw-r--r-- 1 root root 1126 Sep 28 12:32 wsgi.py -rw-r--r-- 1 root root 1000 Sep 28 12:32 wsgi.pyc [root@vps616 www]#
The uwsgi config:
[root@vps616 www]# cat uwsgi.ini [uwsgi] uid = 500 listen=200 master = true profiler = true processes = 8 logdate = true pidfile = /root/www/www.pid daemonize = /root/www/www.log enable-threads = true memory-report = true limit-as = 6048
start command:
uwsgi --ini uwsgi.ini -s 127.0.0.1:8000
thanks a lot.
解决方案Try moving the 404.html, etc... files inside your template directory (where you have your base_site.html if you have)
这篇关于nginx + uwsgi + django,如何配置404.html和502.html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文