2016년 4월 17일 일요일

NGINX+letsencrypt 자동으로 renewal하기

https://vincent.composieux.fr/article/install-configure-and-automatically-renew-let-s-encrypt-ssl-certificate

위의 링크들을 참고하여 진행했다.
cron이 진행되는 시간은 서버시간 기준이기 때문에 서버의 시간을 한국 시간으로 맞췄다.

nginx 설정을 할 때에는

location '/.well-known/acme-challenge' { root /var/www/yourdomain.tld/; try_files $uri /$1; }

$uri와 /$1 사이에 공백이 있다는 사실을 모르고 에러를 계속 보다가 나중에야 공백이 있음을 깨닫고 처리할 수 있었다.

2016년 4월 12일 화요일

AWS + Nginx에서 letsencrypt 설정

letsencrypt를 이용하여 SSL인증서를 받으려 시도했다.
sudo ./letsencrypt-auto certonly --standalone

하지만 다음과 같은 메세지와 함께 계속해서 실패했다.

IMPORTANT NOTES:
 - The following errors were reported by the server:

   Domain: potenup.co.kr
   Type:   connection
   Detail: Failed to connect to host for DVSNI challenge

   Domain: www.potenup.co.kr
   Type:   connection
   Detail: Failed to connect to host for DVSNI challenge

   To fix these errors, please make sure that your domain name was
   entered correctly and the DNS A record(s) for that domain
   contain(s) the right IP address. Additionally, please check that
   your computer has a publicly routable IP address and that no
   firewalls are preventing the server from communicating with the
   client. If you're using the webroot plugin, you should also verify
   that you are serving files from the webroot path you provided.


방법을 찾던중 443 포트가 열려 있어야함을 알게 되었고
AWS console에서 443 TCP 포트를 열어 해결했다.

2016년 4월 8일 금요일

AWS 서울 region에서의 django S3 연동

인터넷에 있는 온갖 예제를 다 따라해봐도 되질 않아 많은 고생 중에 서울과 프랑크푸르트 등 최근에 만들어진 region에서는 다른 종류의 알고리즘을 사용해서 특별한 설정이 필요하다고 한다.

boto와 django-storages를 설치한 뒤

AWS_S3_HOST = 's3.ap-northeast-2.amazonaws.com'AWS_QUERYSTRING_AUTH = FalseAWS_ACCESS_KEY_ID = 'xxxxxxxxxxxxxxxxxxxxxxxxx'AWS_SECRET_ACCESS_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxx'AWS_STORAGE_BUCKET_NAME = 'xxxxxxxx'DEFAULT_FILE_STORAGE = "storages.backends.s3boto.S3BotoStorage"
MEDIA_URL = 'http://%s.s3.amazonaws.com/' % AWS_STORAGE_BUCKET_NAME

위와 같이 설정하여 해결했다.

2016년 4월 6일 수요일

python virtual enviornment에서 mysql connector 설치

MySQL을 django에 연동하려 했지만 MySQL정식 사이트에서 받은 connector를 암만 설치해도 동작하지 않아 어려움을 겪던 중, 해당 connector를 가상환경에 설치해야만 한다는 것을 뒤늦게 깨달았다.

설치하는 방법은 다음과 같았다.

pip install https://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.1.3.tar.gz

물론 URL은 얼마든지 바뀔 수 있다.