나는 장고 응용 프로그램을 배포 할 때 https://ashokfernandez.wordpress.com/2014/03/11/deploying-a-django-app-to-amazon-aws-with-nginx-gunicorn-git/ 에서 자습서를 진행했습니다. 이것은 현재 상황입니다 :nginx + gunicorn + django + aws 나쁜 요청
fab spawn 인스턴스가 nginx 및 gunicorn이 설치된 aws 인스턴스를 만들었지 만 해당 컴퓨터에서 사이트에 액세스하려고 시도했을 때 400 번의 잘못된 요청이 발생했습니다. nginx 오류 로그를 검사했지만 비어 있었고 nginx 액세스 로그는 요청을 받았음을 나타 냈습니다. 감독자 로그에 다음했다 : 다음 [ "*"]
[2015-01-31 21:26:20 +0000] [15823] [INFO] Starting gunicorn 19.2.0
[2015-01-31 21:26:20 +0000] [15823] [INFO] Listening at: http://127.0.0.1:8002/ (15823)
[2015-01-31 21:26:20 +0000] [15823] [INFO] Using worker: sync
[2015-01-31 21:26:20 +0000] [15832] [INFO] Booting worker with pid: 15832
[2015-01-31 21:26:20 +0000] [15833] [INFO] Booting worker with pid: 15833
[2015-01-31 21:26:20 +0000] [15834] [INFO] Booting worker with pid: 15834
[2015-01-31 21:26:20 +0000] [15835] [INFO] Booting worker with pid: 15835
[2015-01-31 21:26:20 +0000] [15836] [INFO] Booting worker with pid: 15836
[2015-01-31 21:26:31 +0000] [15837] [INFO] Starting gunicorn 19.2.0
[2015-01-31 21:26:31 +0000] [15837] [ERROR] Connection in use: (‘127.0.0.1′, 8002)
[2015-01-31 21:26:31 +0000] [15837] [ERROR] Retrying in 1 second.
[2015-01-31 21:26:32 +0000] [15837] [ERROR] Connection in use: (‘127.0.0.1′, 8002)
[2015-01-31 21:26:32 +0000] [15837] [ERROR] Retrying in 1 second.
[2015-01-31 21:26:33 +0000] [15837] [ERROR] Connection in use: (‘127.0.0.1′, 8002)
[2015-01-31 21:26:33 +0000] [15837] [ERROR] Retrying in 1 second.
[2015-01-31 21:26:34 +0000] [15837] [ERROR] Connection in use: (‘127.0.0.1′, 8002)
[2015-01-31 21:26:34 +0000] [15837] [ERROR] Retrying in 1 second.
[2015-01-31 21:26:35 +0000] [15837] [ERROR] Connection in use: (‘127.0.0.1′, 8002)
[2015-01-31 21:26:35 +0000] [15837] [ERROR] Retrying in 1 second.
[2015-01-31 21:26:36 +0000] [15837] [ERROR] Can’t connect to (‘127.0.0.1′, 8002)
[2015-01-31 21:26:37 +0000] [15846] [INFO] Starting gunicorn 19.2.0
[2015-01-31 21:26:37 +0000] [15846] [INFO] Listening at: http://127.0.0.1:8002 (15846)
[2015-01-31 21:26:37 +0000] [15846] [INFO] Using worker: sync
[2015-01-31 21:26:37 +0000] [15855] [INFO] Booting worker with pid: 15855
[2015-01-31 21:26:37 +0000] [15856] [INFO] Booting worker with pid: 15856
[2015-01-31 21:26:37 +0000] [15857] [INFO] Booting worker with pid: 15857
[2015-01-31 21:26:38 +0000] [15858] [INFO] Booting worker with pid: 15858
[2015-01-31 21:26:38 +0000] [15859] [INFO] Booting worker with pid: 15859
내가가 []에서 ALLOWED_HOSTS을 변경하고를 '*' 내가 문자열로 변경할 때, 나는 "가지고 요청한 URL을 /를 찾을 수 없습니다 이 서버에. " 다른 경우 400 건의 잘못된 요청이 있습니다.
nginx에서 장고 앱을 배포하는 것은 이번이 처음이며 문제가 무엇인지 파악할 수 없습니다. 이 오류를 디버그하도록 도와 주시겠습니까? 미리 감사드립니다 !!
추신 : 설정 파일을 게시해야하는지 알려주세요. 지금까지 나는이 튜토리얼을 따라했으며 구성을 변경하지 않았습니다.
UPDATE :
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
SECRET_KEY = 'blah'
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
ROOT_URLCONF = 'mosaic.urls'
WSGI_APPLICATION = 'mosaic.wsgi.application'
# Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
이 prod.py 내 프로젝트 설정 파일에서 또한
from mosaic.settings.common import *
DEBUG = True #Change this after the project starts working
TEMPLATE_DEBUG = True
ALLOWED_HOSTS = []
# Database
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'mosaic',
'USER' : 'adminuser',
'PASSWORD' : '****',
'HOST' : 'abcd.cjcgmgnogsvc.us-west-1.rds.amazonaws.com',
'PORT' : '5432',
}
}
# Static files via Amazon S3 (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.6/howto/static-files/
INSTALLED_APPS += ('storages',)
AWS_STORAGE_BUCKET_NAME = "xyz"
STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
S3_URL = 'http://%s.s3.amazonaws.com/' % AWS_STORAGE_BUCKET_NAME
STATIC_URL = S3_URL
는 내가 "" fabconf [ '도메인'] =이 내가이 생각 common.py가 수도 관련성이 높습니다.
답장을 보내 주셔서 감사합니다. 난 장고 설정 파일로 질문을 업데이 트했습니다. 나는 아직도 400 나쁜 요구를 얻는다. – warun26