Welcome! Log In Create A New Profile

Advanced

Re: Proxy_cache

October 11, 2017 01:55AM
В общем решили на каждом Nginx держать свой кэш. и с помощью sync2 делать синхронизацию этого кэша.
Если один nginx отвалится то LB перенаправит на другой. как бы все ок.
Тут у меня другая проблема появилась, уже моск весь сломал. не отдает gunicorn стили.

[error] 11431#0: *1 open() "/root/env/myproject/static/admin/css/login.css" failed (13: Permission denied), client: 192.168.200.46, server: 10.230.40.190, request: "GET /static/admin/css/login.css HTTP/1.1", host: "10.230.40.188", referrer: "http://10.230.40.188/admin/login/?next=/admin/"

blog.conf

server {
listen 80;
server_name 10.230.40.190;
location / {
proxy_pass http://10.230.40.190:8009;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
}

location /static/ {

autoindex off;
root /root/env/myproject;
}

setting.py
import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
RESOURCE_DIR = os.path.dirname(BASE_DIR)

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'grj&8iul8=*5-!nbaf-86*+*3s!j%%pj(wdjg$x+jalbet@shm'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

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 = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'myproject.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'myproject.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'gunicorn',
'USER': 'gunicorn',
'PASSWORD': 'gunicorn',
'HOST': '10.230.40.194',
'PORT': '5432',
}
}

# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]


# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/

LANGUAGE_CODE = 'ru-ru'

TIME_ZONE = 'Asia/Almaty'

USE_I18N = True

USE_L10N = True
USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
STATIC_ROOT = os.path.join(RESOURCE_DIR, 'static')
STATIC_URL = '/static/'
MEDIA_ROOT = os.path.join(RESOURCE_DIR, 'media')
MEDIA_URL = '/media/'
TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]

}

Когда захожу на сервер gunicorn напрямую http://10.230.40.190:8009/admin в консоли ошибки
Not Found: /static/admin/css/login.css
Not Found: /static/admin/css/base.css
Не могу понять, где он пытается найти папку static? в корне что ли? Я везде симлинки понаделал, результата 0
Subject Author Posted

proxy_cache

Eugene Toropov August 23, 2010 11:00AM

Re: proxy_cache

Igor Sysoev August 23, 2010 11:02AM

Re: proxy_cache

Eugene Toropov August 23, 2010 11:08AM

Re: proxy_cache

ALex_hha June 29, 2016 06:28AM

Re: proxy_cache

sejo412 June 30, 2016 02:32PM

Re: Proxy_cache

Andrey Kopeyko October 07, 2017 08:44AM

Re: Proxy_cache

kpoxa October 09, 2017 07:14AM

Re: Proxy_cache

Илья Шипицин October 09, 2017 07:28AM

Re: Proxy_cache

demolitionman October 11, 2017 01:55AM

Re: Proxy_cache

demolitionman October 11, 2017 06:06AM

Re: Proxy_cache

demolitionman October 11, 2017 11:18PM

Re: Proxy_cache

demolitionman October 11, 2017 11:19PM

Re: Proxy_cache

Dmitriy Lyalyuev October 12, 2017 02:08AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 68
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready