아무거나 끄적끄적로그인

Thumbor 설치

Ubuntu 16.04 , 이미지 서비스

by elicie2018. 02. 23. 12:00

이미지 서비스인 Thumbor 설치 문서


라이브러리 설치

sudo apt-get -y install build-essential checkinstall gcc python python-dev libpng12-dev libtiff5-dev libpng-dev libjasper-dev libwebp-dev libcurl4-openssl-dev python-pgmagick libmagick++-dev graphicsmagick libopencv-dev python-pip libssl-dev

sudo pip install pycurl

Thumbor 설치

sudo pip install thumbor

thumbor-config > thumbor.conf
sudo mv thumbor.conf /etc/

sudo apt-get install python-opencv

aws 라이브라리 설치

sudo pip install tc_aws

aws 용 셋팅

sudo vi /etc/nthumbor.conf

### 맨 상단에 추가
################################## AWS 
TC_AWS_REGION='ap-northeast-2' # AWS Region

TC_AWS_STORAGE_BUCKET='버킷명' # S3 bucket for Storage
TC_AWS_STORAGE_ROOT_PATH='' # S3 path prefix for Storage bucket

TC_AWS_LOADER_BUCKET='버킷명' #S3 bucket for loader
TC_AWS_LOADER_ROOT_PATH='' # S3 path prefix for Loader bucket

TC_AWS_RESULT_STORAGE_BUCKET='버킷명' # S3 bucket for result Storage
TC_AWS_RESULT_STORAGE_ROOT_PATH='result' # S3 path prefix for Result storage bucket

# put data into S3 using the Server Side Encryption functionality to
# encrypt data at rest in S3
# https://aws.amazon.com/about-aws/whats-new/2011/10/04/amazon-s3-announces-server-side-encryption-support/
TC_AWS_STORAGE_SSE=False

# put data into S3 with Reduced Redundancy
# https://aws.amazon.com/about-aws/whats-new/2010/05/19/announcing-amazon-s3-reduced-redundancy-storage/
TC_AWS_STORAGE_RRS=False


# Enable HTTP Loader as well?
# This would allow you to load watermarks in over your images dynamically through a URI
# E.g.
# http://your-thumbor.com/unsafe/filters:watermark(http://example.com/watermark.png,0,0,50)/s3_bucket/photo.jpg
TC_AWS_ENABLE_HTTP_LOADER=False

TC_AWS_ALLOWED_BUCKETS=False # List of allowed bucket to be requested
TC_AWS_STORE_METADATA=False # Store result with metadata (for instance content-type)
TC_AWS_MAX_RETRY=5
RESULT_STORAGE_STORES_UNSAFE = True

LOADER = 'tc_aws.loaders.s3_loader'
STORAGE = 'thumbor.storages.no_storage'
RESULT_STORAGE = 'tc_aws.result_storages.s3_storage'
RESULT_STORAGE_AWS_STORAGE_ROOT_PATH = 'tc_aws.result_storages.s3_storage'
#SECURITY_KEY = 'MY_SECURE_KEY'
#ALLOW_UNSAFE_URL = False


DETECTORS = [
    'thumbor.detectors.face_detector',
]
* AWS APIKey, SecretKey 설정이 필요함. IAM


nginx 설정

upstream thumbor  {
    server 127.0.0.1:8888;
}

server {
    listen       80;
    server_name  '도메인명';
    client_max_body_size 30M;

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header HOST $http_host;
        proxy_set_header X-NginX-Proxy true;

        proxy_pass http://thumbor;
        proxy_redirect off;
    }
}

thumbor 실행

/usr/bin/python /usr/local/bin/thumbor --conf /etc/thumbor.conf