Q&A
책을 따라하다가 막히는 부분이 있나요?
질문을 남겨주세요.
이 페이지는 의견 교환을 위해 따로 만든 페이지입니다. 책에서 이 페이지를 만드는 법을 직접적으로 다루지는 않습니다.
하지만, 책을 끝까지 읽고 나면 이 페이지도 만드실 수 있을거에요.
하지만, 책을 끝까지 읽고 나면 이 페이지도 만드실 수 있을거에요.
aws 서버 연결 오류입니다.
6 months, 3 weeks ago
며칠 동안 이것만 했는데 도저히 안 됩니다.
계속 사이트에 연결할 수 없다고 나옵니다.
오타 아니고, 포트 열려 있고, 도메인도 제대로 설정했습니다.
상태 검사 하면 다 연결 안 됩니다. 당연히 인증서 발급도 안 됩니다.
docker-compose.yml
------------------------------------------------------
version: '3'
services:
nginx:
build: ./nginx
volumes:
- static_volume:/usr/src/app/_static
- media_volume:/usr/src/app/_media
- ./data/certbot/conf:/etc/letsencrypt
- ./data/certbot/www:/var/www/certbot
ports:
- 80:80
- 443:443
depends_on:
- web
certbot:
image: certbot/certbot
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
volumes:
- ./data/certbot/conf:/etc/letsencrypt
- ./data/certbot/www:/var/www/certbot
web:
build: .
command: gunicorn do_it_django_prj.wsgi:application --bind 0.0.0.0:8000
volumes:
- static_volume:/usr/src/app/_static
- media_volume:/usr/src/app/_media
- ./:/usr/src/app/
expose:
- 8000
env_file:
- ./.env.prod
depends_on:
- db
db:
image: postgres:15.8-alpine
volumes:
- postgres_data:/var/lib/postgresql/data/
env_file:
- ./.env.prod.db
volumes:
postgres_data:
static_volume:
media_volume:
------------------------------------------------------
.env.prod
------------------------------------------------------
DEBUG = 1
SECRET_KEY = .........
DJANGO_ALLOWED_HOSTS = localhost 127.0.0.1 13.124.251.0 ysh195dev.com www.ysh195dev.com [::1]
SQL_ENGINE=django.db.backends.postgresql
SQL_DATABASE=postgresDB
SQL_USER=postgres
SQL_PASSWORD=9423
SQL_HOST=db
SQL_PORT=5432
------------------------------------------------------
nginx.conf
------------------------------------------------------
upstream ysh195dev {
server web:8000;
}
server {
listen 80;
server_name ysh195dev.com;
location / {
return 301 https://$host$request_uri;
}
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
}
server {
listen 443 ssl;
server_name ysh195dev.com;
location / {
proxy_pass http://ysh195dev;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
}
location /static/ {
alias /usr/src/app/_static/;
}
location /media/ {
alias /usr/src/app/_media/;
}
ssl_certificate /etc/letsencrypt/live/ysh195dev.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/ysh195dev.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}
------------------------------------------------------
setting.py
------------------------------------------------------
(생략)
SITE_ID = 1 # SITE_ID = 1이면 나중에 사이트 만들었을 때 example.comd이라는 도메인으로 생성됨
ACCOUNT_EMAIL_REQUIRED = True # 회원가입 시 이메일 필요하게 설정
ACCOUNT_EMAIL_VERIFICATION = "none" # 하지만 그 이메일이 맞는지 검증하는 기능은 비활성화
LOGIN_REDIRECT_URL = "/blog/" # 로그인 성공 시 redirect 될 경로
LOGOUT_REDIRECT_URL = "/blog/" # 로그아웃 성공 시 redirect 될 경로
# 회원 가입 및 로그인, 인증 - 종료
ACCOUNT_DEFAULT_HTTP_PROTOCOL = "https"
X_FRAME_OPTIONS = "SAMEORIGIN"
-------------------------------------------------------
구글 검색해봐도 안 나오고, 챗gpt 물어봐도 안 나옵니다. 도대체 뭘 어떻게 해야 하나요? 답답해서 미치겠네요
목록보기
sungyong 6 months, 3 weeks ago
안녕하세요. 거의 끝까지 왔는데 웹사이트 공개가 안되니 더 답답하실 것 같습니다. 저도 지금 원인을 파악하지 못하고 있는데요. 혹시 도커를 띄울 때 에러는 없었나요?
docker-compose down 하신 뒤, docker-compose up 한 결과 알려주시겠어요? 그 상태에서 어떤 에러 메시지가 뜨진 않는지 확인해주실 수 있나요?
Updated: Sept. 8, 2024, 11:46 p.m.
연상훈 6 months, 3 weeks ago
docker-compose down > docker-compose up 할 때 에러는 전혀 없습니다.
그리고 이건 터미널에 sudo ./init-letsencrypt.sh을 입력했을 때의 결과입니다.
Certbot failed to authenticate some domains (authenticator: webroot). The Certificate Auth
ority reported these problems:
Domain: www.ysh195dev.com
Type: dns
Detail: DNS problem: NXDOMAIN looking up A for www.ysh195dev.com - check that a DNS reco
rd exists for this domain; DNS problem: NXDOMAIN looking up AAAA for www.ysh195dev.com - c
heck that a DNS record exists for this domain
Domain: ysh195dev.com
Type: dns
Detail: no valid A records found for ysh195dev.com; no valid AAAA records found for ysh1
95dev.com
Hint: The Certificate Authority failed to download the temporary challenge files created b
y Certbot. Ensure that the listed domains serve their content from the provided --webroot-
path/-w and that files created there can be downloaded from the internet.
Some challenges have failed.
Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile
/var/log/letsencrypt/letsencrypt.log or re-run Certbot with -v for more details.
ERROR: 1
### Reloading nginx ...
2024/09/08 16:55:55 [emerg] 22#22: cannot load certificate "/etc/letsencrypt/live/ysh195de
v.com/fullchain.pem": BIO_new_file() failed (SSL: error:80000002:system library::No such f
ile or directory:calling fopen(/etc/letsencrypt/live/ysh195dev.com/fullchain.pem, r) error
:10000080:BIO routines::no such file)
nginx: [emerg] cannot load certificate "/etc/letsencrypt/live/ysh195dev.com/fullchain.pem"
: BIO_new_file() failed (SSL: error:80000002:system library::No such file or directory:cal
ling fopen(/etc/letsencrypt/live/ysh195dev.com/fullchain.pem, r) error:10000080:BIO routin
es::no such file)
Updated: Sept. 9, 2024, 1:58 a.m.
sungyong 6 months, 3 weeks ago
그럼 .init-letsencrypt 하기 전에는 http로 연결이 되었었나요?
Updated: Sept. 9, 2024, 11:04 p.m.
연상훈 6 months, 3 weeks ago
그 전부터 localhost만 연결되고, 도메인이나 고정 ip로는 안 됐습니다. 그리고 이것저것 만지다가 지금은 초기 상태로 돌려놨는데, 지금은 localhost도 안 됩니다.
aws 옮기기 전에 도커 환경에서는 localhost 정상작동했습니다
Updated: Sept. 10, 2024, 1:06 a.m.
연상훈 6 months, 3 weeks ago
aws연결할 때 책과 다르게 한 점은 장고와 파이썬의 버전, 그리고 보안의 문제로 제 깃허브와 연결이 안 되길래 ssh키를 생성해서 제 깃허브와 연결한 점 뿐입니다.
Updated: Sept. 10, 2024, 1:13 a.m.
sungyong 6 months, 3 weeks ago
안되던 단계에서 원인을 찾으면 좋을텐데. 일단은 고정ip로 하는 부분부터 시도해보면서 차근차근 원인을 찾아봐야 할 것 같습니다. 저도 더 살펴보겠습니다.
Updated: Sept. 11, 2024, 10:46 p.m.
sungyong 6 months, 3 weeks ago
책으로 뭔가 놓치고 있다고 느끼신다면 라이브로 녹화해놓은 버전이 인프런에 있습니다.
배포 부분은 무료로 보실 수 있으니까 확인해보세요.
Do It! 장고+부트스트랩: 파이썬 웹개발의 정석 강의 | SungYong Lee - 인프런 (inflearn.com)
Updated: Sept. 11, 2024, 11:49 p.m.
Leave a Comment: