위의 블로그의 코드입니다. 저기 블로그에서 그대로 복사하면 코드가 엔터가 안먹어서 따로 정리합니다.
uwsgi.ini
[uwsgi]
socket = /srv/docker-server/apps.sock
master = true
processes = 1
threads = 2
chdir = /srv/docker-server
module = server_dev.wsgi
logto = /var/log/uwsgi/uwsgi.log
log-reopen = true vacuum = true
vacuum = true
nginx.conf
# ~/docker-server/nginx/nginx.conf
user root;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 1024;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
# include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
nginx-app.conf
upstream uwsgi {
server unix:/srv/docker-server/apps.sock;
}
server {
listen 80;
server_name localhost;
charset utf-8;
client_max_body_size 128M;
location / {
uwsgi_pass uwsgi;
include uwsgi_params;
}
location /media/ {
alias /srv/docker-server/.media/;
}
location /static/ {
alias /srv/docker-server/.static/;
}
}
nginx Dockerfile
# ~/docker_server/nginx/Dockerfile
FROM nginx:latest
COPY nginx.conf /etc/nginx/nginx.conf
COPY nginx-app.conf /etc/nginx/sites-available/
RUN mkdir -p /etc/nginx/sites-enabled/\
&& ln -s /etc/nginx/sites-available/nginx-app.conf /etc/nginx/sites-enabled/
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
docker-compose
version: '3'
services:
nginx:
container_name: nginx
build: ./nginx
image: docker-server/nginx
restart: always
ports:
- "80:80"
volumes:
- ./server_dev:/srv/docker-server
- ./log:/var/log/nginx
depends_on:
- django
django:
container_name: django
build: ./server_dev
image: docker-server/django
restart: always
command: uwsgi --ini uwsgi.ini
volumes:
- ./server_dev:/srv/docker-server
- ./log:/var/log/uwsgi
'개발 > Django' 카테고리의 다른 글
DJango admin pwd 변경 (0) | 2020.09.24 |
---|---|
Django 회원가입 로그인 로그아웃 (0) | 2020.09.09 |
Docker compose (0) | 2020.09.04 |
Django EC2배포 (0) | 2020.08.27 |
장고 파이참 admin 오류 (0) | 2020.07.16 |