关于nginx的一些异常及解决办法的汇总

1. django + uwsgi + nginx

    XMLHttpRequest cannot load http://127.0.0.1  No 'Access-Control-Allow-Origin' header is present on the requested resource.

    Origin 'http://127.0.0.1:8100' is therefore not allowed access.

解决办法:

#django ../../setting.py
MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    #'django.middleware.csrf.CsrfViewMiddleware', # 需要注释掉
......
)
$vi /etc/nginx/nginx.conf
add_header Access-Control-Allow-Origin *;

 

posted @ 2015-07-09 15:44  开心星  阅读(413)  评论(0)    收藏  举报