├── ansible.cfg ├── templates ├── thumbor.key.j2 ├── upstart-thumbor-worker.conf.j2 ├── upstart-thumbor.conf.j2 ├── default-thumbor.j2 ├── nginx-site.conf.j2 └── thumbor.conf.j2 ├── vars └── main.yml ├── handlers └── main.yml ├── test.yml ├── meta └── main.yml ├── defaults └── main.yml ├── .gitignore ├── Vagrantfile ├── README.md ├── tasks └── main.yml └── LICENSE /ansible.cfg: -------------------------------------------------------------------------------- 1 | [defaults] 2 | roles_path = ../ 3 | -------------------------------------------------------------------------------- /templates/thumbor.key.j2: -------------------------------------------------------------------------------- 1 | 5a1iBXJaayZ1fWvzFHcbu2bLVi(bDFqzpdx)v1GpdmTL#5)PKZB)Z8kebW-7KcGC 2 | -------------------------------------------------------------------------------- /vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | thumbor_aws_access_key: '' 3 | thumbor_aws_secret_key: '' 4 | thumbor_aws_loader_bucket: '' 5 | -------------------------------------------------------------------------------- /handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: restart nginx 3 | service: name=nginx state=restarted 4 | 5 | - name: restart thumbor 6 | service: name=thumbor state=restarted 7 | -------------------------------------------------------------------------------- /test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: all 3 | roles: 4 | - ansible-thumbor 5 | vars: 6 | nginx_remove_default: yes 7 | nginx_worker_processes: 1 8 | nginx_worker_connections: 1024 9 | -------------------------------------------------------------------------------- /meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | galaxy_info: 3 | author: Matthew Finlayson 4 | description: Installs and configures thumbor with aws backing 5 | company: Jive Software 6 | platforms: 7 | - name: Ubuntu 8 | versions: 9 | - All 10 | categories: 11 | - system 12 | dependencies: 13 | - franklinkim.nginx 14 | -------------------------------------------------------------------------------- /templates/upstart-thumbor-worker.conf.j2: -------------------------------------------------------------------------------- 1 | description "Thumbor image manipulation service" 2 | author "Wichert Akkerman " 3 | 4 | stop on stopped thumbor 5 | 6 | respawn 7 | respawn limit 5 10 8 | umask 022 9 | 10 | setuid {{thumbor_user}} 11 | setgid {{thumbor_group}} 12 | 13 | env DAEMON=/usr/local/bin/thumbor 14 | 15 | env conffile={{thumbor_config_file}} 16 | env keyfile={{thumbor_key_file}} 17 | env ip={{thumbor_bind_address}} 18 | 19 | chdir /var/lib/thumbor 20 | 21 | instance $p 22 | 23 | exec $DAEMON -c "${conffile}" -i "${ip}" -k "${keyfile}" -p "${p}" 24 | -------------------------------------------------------------------------------- /templates/upstart-thumbor.conf.j2: -------------------------------------------------------------------------------- 1 | description "Thumbor image manipulation service" 2 | 3 | start on filesystem and runlevel [2345] 4 | stop on runlevel [!2345] 5 | 6 | console output 7 | 8 | env port=8888 9 | 10 | pre-start script 11 | [ -r /etc/default/thumbor ] && . /etc/default/thumbor 12 | if [ "$enabled" = "0" ] && [ "$force" != "1" ] ; then 13 | logger -is -t "$UPSTART_JOB" "Thumbor is disabled by /etc/default/thumbor, add force=1 to your service command" 14 | stop 15 | exit 0 16 | fi 17 | for p in `echo ${port} | tr ',' ' '`; do 18 | start thumbor-worker p=$p 19 | done 20 | end script 21 | -------------------------------------------------------------------------------- /defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # defaults file for ansible-thumbor 3 | thumbor_aws_version: a0c4bcc02601af317072adab32ce0be14d0cd492 4 | thumbor_server_name: localhost 5 | thumbor_user: thumbor 6 | thumbor_group: thumbor 7 | thumbor_home: /home/thumbor 8 | thumbor_config_file: /etc/thumbor.conf 9 | thumbor_key_file: /etc/thumbor.key 10 | thumbor_log_file: /var/log/thumbor 11 | thumbor_working_directory: /var/lib/thumbor 12 | thumbor_default: /etc/default/thumbor 13 | thumbor_server_name: localhost 14 | thumbor_bind_address: 127.0.0.1 15 | thumbor_loader: thumbor.loaders.http_loader 16 | thumbor_storage: thumbor.storages.file_storage 17 | thumbor_result_storage: None 18 | thumbor_max_age: 31536000 19 | -------------------------------------------------------------------------------- /templates/default-thumbor.j2: -------------------------------------------------------------------------------- 1 | # set this to 0 to disable thumbor, remove or set anything else to enable it 2 | # you can temporarily override this with 3 | # sudo service thumbor start force=1 4 | enabled=1 5 | 6 | # Location of the configuration file 7 | conffile=/etc/thumbor.conf 8 | 9 | # Location of the keyfile which contains the signing secret used in URLs 10 | #keyfile=/etc/thumbor.key 11 | 12 | # IP address to bind to. Defaults to all IP addresses 13 | # ip=127.0.0.1 14 | 15 | # TCP port to bind to. Defaults to port 8888. 16 | # multiple instances of thumbor can be started by putting several ports coma separeted 17 | # Ex: 18 | # port=8888,8889,8890 19 | # or 20 | # port=8888 #Default 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | 5 | # C extensions 6 | *.so 7 | 8 | # Distribution / packaging 9 | .Python 10 | env/ 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | lib/ 17 | lib64/ 18 | parts/ 19 | sdist/ 20 | var/ 21 | *.egg-info/ 22 | .installed.cfg 23 | *.egg 24 | 25 | # PyInstaller 26 | # Usually these files are written by a python script from a template 27 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 28 | *.manifest 29 | *.spec 30 | 31 | # Installer logs 32 | pip-log.txt 33 | pip-delete-this-directory.txt 34 | 35 | # Unit test / coverage reports 36 | htmlcov/ 37 | .tox/ 38 | .coverage 39 | .cache 40 | nosetests.xml 41 | coverage.xml 42 | 43 | # Translations 44 | *.mo 45 | *.pot 46 | 47 | # Django stuff: 48 | *.log 49 | 50 | # Sphinx documentation 51 | docs/_build/ 52 | 53 | # PyBuilder 54 | target/ 55 | .vagrant 56 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.configure("2") do |config| 5 | config.vm.network :private_network, ip: "192.168.33.99" 6 | config.vm.network :forwarded_port, guest: 22, host: 2299 7 | 8 | config.vm.define 'ubuntu1404-amd64' do |instance| 9 | 10 | # Every Vagrant virtual environment requires a box to build off of. 11 | instance.vm.box = 'ubuntu1404-amd64' 12 | 13 | # The url from where the 'config.vm.box' box will be fetched if it 14 | # doesn't already exist on the user's system. 15 | instance.vm.box_url = 'https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box' 16 | 17 | # View the documentation for the provider you're using for more 18 | # information on available options. 19 | config.vm.provision "ansible" do |ansible| 20 | ansible.playbook = "test.yml" 21 | ansible.verbose = 'vv' 22 | ansible.sudo = true 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Ansible Thumbor 2 | ========= 3 | 4 | `thumbor` is an [ansible](http://www.ansible.com) role which: 5 | 6 | * installs nginx 7 | * installs thumbor 8 | * configures thumbor 9 | * starts both as services 10 | 11 | Installation 12 | ------------ 13 | 14 | Using `ansible-galaxy`: 15 | 16 | ``` 17 | $ ansible-galaxy install savagegus.thumbor 18 | ``` 19 | 20 | Using `git`: 21 | 22 | ``` 23 | $ git clone https://github.com/jivesoftware/ansible-thumbor.git 24 | ``` 25 | 26 | Role Variables 27 | -------------- 28 | 29 | ``` 30 | thumbor_aws_access_key: '' 31 | thumbor_aws_secret_key: '' 32 | thumbor_aws_loader_bucket: '' 33 | thumbor_aws_version: a0c4bcc02601af317072adab32ce0be14d0cd492 34 | thumbor_server_name: localhost 35 | thumbor_user: thumbor 36 | thumbor_group: thumbor 37 | thumbor_home: /home/thumbor 38 | thumbor_config_file: /etc/thumbor.conf 39 | thumbor_key_file: /etc/thumbor.key 40 | thumbor_log_file: /var/log/thumbor 41 | thumbor_working_directory: /var/lib/thumbor 42 | thumbor_default: /etc/default/thumbor 43 | thumbor_server_name: localhost 44 | thumbor_bind_address: 127.0.0.1 45 | thumbor_loader: thumbor_aws.loaders.s3_loader 46 | ``` 47 | 48 | Dependencies 49 | ------------ 50 | 51 | franklinkim.nginx 52 | 53 | Example Playbook 54 | ---------------- 55 | 56 | ``` 57 | - hosts: all 58 | roles: 59 | - ansible-thumbor 60 | vars: 61 | nginx_remove_default: yes 62 | nginx_worker_processes: 1 63 | nginx_worker_connections: 1024 64 | thumbor_aws_access_key: XXX 65 | thumbor_aws_secret_key: XXX 66 | thumbor_aws_loader_bucket: XXX 67 | ``` 68 | 69 | Testing 70 | _______ 71 | 72 | ``` 73 | $ git clone https://github.com/jivesoftware/ansible-thumbor.git 74 | $ cd ansible-thumbor 75 | $ vagrant up 76 | ``` 77 | 78 | Contributing 79 | ____________ 80 | 81 | In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests and examples for any new or changed functionality. 82 | 83 | 1. Fork it 84 | 2. Create your feature branch (`git checkout -b my-new-feature`) 85 | 3. Commit your changes (`git commit -am 'Add some feature'`) 86 | 4. Push to the branch (`git push origin my-new-feature`) 87 | 5. Create new Pull Request 88 | 89 | License 90 | _______ 91 | 92 | Copyright (c) Jive Software under the Apache license. 93 | -------------------------------------------------------------------------------- /templates/nginx-site.conf.j2: -------------------------------------------------------------------------------- 1 | #user nobody; 2 | worker_processes 1; 3 | 4 | #error_log /var/log/error.log debug; 5 | #error_log logs/error.log notice; 6 | #error_log logs/error.log info; 7 | 8 | #rewrite_log on; 9 | #pid logs/nginx.pid; 10 | 11 | 12 | events { 13 | worker_connections 1024; 14 | } 15 | 16 | http { 17 | # A virtual host using mix of IP-, name-, and port-based configuration 18 | # 19 | 20 | upstream thumbor { 21 | server localhost:8888; 22 | } 23 | 24 | server { 25 | listen 80; 26 | server_name {{ thumbor_server_name }}; 27 | client_max_body_size 10M; 28 | rewrite_log on; 29 | 30 | location ^~ /images { 31 | # get there only if we have a query string 32 | if ($is_args) { 33 | set $width "0"; 34 | set $height "0"; 35 | set $mode ""; 36 | set $result ""; 37 | } 38 | 39 | if ($args ~* "(?:^|&)width=([^&]+)") { 40 | set $width $1; 41 | set $dim "${width}x${height}"; 42 | set $result "${dim}"; 43 | } 44 | 45 | if ($args ~* "(?:^|&)height=([^&]+)") { 46 | set $height $1; 47 | # string concatenation using sort of bash syntax 48 | set $dim "${width}x${height}"; 49 | set $result "${dim}"; 50 | } 51 | 52 | if ($args ~* "(?:^|&)mode=([^&]+)") { 53 | set $mode $1; 54 | } 55 | 56 | if ($mode = "smart") { 57 | set $result "${dim}/smart"; 58 | } 59 | 60 | if ($mode = "fit-in") { 61 | set $result "fit-in/${dim}"; 62 | } 63 | 64 | if ($is_args) { 65 | # the ? here prevent query string from being appended 66 | rewrite ^/images(/.*)$ /unsafe/$result/$1? last; 67 | } 68 | 69 | rewrite ^/images(/.*)$ /unsafe/$1 last; 70 | } 71 | 72 | location ~ /unsafe { 73 | proxy_set_header X-Real-IP $remote_addr; 74 | proxy_set_header HOST $http_host; 75 | proxy_set_header X-NginX-Proxy true; 76 | 77 | proxy_pass http://thumbor; 78 | proxy_redirect off; 79 | } 80 | 81 | location = /favicon.ico { 82 | return 204; 83 | access_log off; 84 | log_not_found off; 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: create group 3 | group: > 4 | name={{thumbor_group}} 5 | state=present 6 | 7 | - name: create user 8 | user: > 9 | name={{thumbor_user}} 10 | group={{thumbor_group}} 11 | 12 | - name: update apt 13 | apt: update_cache=yes 14 | 15 | - name: install pgmagick deps 16 | apt: pkg={{item}} 17 | with_items: 18 | - python-pgmagick 19 | - python-pip 20 | - python-dev 21 | - git-core 22 | - libjpeg-dev 23 | - libtiff-dev 24 | - libpng-dev 25 | - libjasper-dev 26 | - libwebp-dev 27 | 28 | - name: install pgmagick 29 | pip: > 30 | name={{item}} 31 | with_items: 32 | - pycurl 33 | - numpy 34 | - thumbor 35 | - boto 36 | # this will be needed for the aws_storage to work but dateutil is not the correct name 37 | # - dateutil 38 | - git+https://github.com/willtrking/thumbor_aws.git@{{ thumbor_aws_version }}#egg=thumbor_aws 39 | 40 | - name: copy nginx config 41 | template: > 42 | src=nginx-site.conf.j2 43 | dest=/etc/nginx/nginx.conf 44 | owner=root 45 | group=root 46 | mode=0755 47 | 48 | - name: copy thumbor conf default 49 | template: > 50 | src=thumbor.conf.j2 51 | dest={{ thumbor_config_file }} 52 | owner=root 53 | group=root 54 | mode=0755 55 | 56 | - name: copy thumbor upstart script 57 | template: > 58 | src=upstart-thumbor.conf.j2 59 | dest=/etc/init/thumbor.conf 60 | owner=root 61 | group=root 62 | mode=644 63 | 64 | - name: copy thumbor key 65 | template: > 66 | src=thumbor.key.j2 67 | dest={{ thumbor_key_file }} 68 | owner=root 69 | group=root 70 | mode=0755 71 | 72 | - name: working dir 73 | file: > 74 | path={{thumbor_working_directory}} 75 | owner=root 76 | group=root 77 | mode=0644 78 | state=directory 79 | 80 | - name: copy thumbor upstart script 81 | template: > 82 | src=upstart-thumbor.conf.j2 83 | dest=/etc/init/thumbor.conf 84 | owner=root 85 | group=root 86 | mode=644 87 | 88 | - name: copy thumbor worker upstart script 89 | template: > 90 | src=upstart-thumbor-worker.conf.j2 91 | dest=/etc/init/thumbor-worker.conf 92 | owner=root 93 | group=root 94 | mode=644 95 | 96 | - service: > 97 | name=thumbor 98 | state=restarted 99 | enabled=yes 100 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /templates/thumbor.conf.j2: -------------------------------------------------------------------------------- 1 | ################################### Logging #################################### 2 | 3 | ## Log Format to be used by thumbor when writing log messages. 4 | ## Defaults to: %(asctime)s %(name)s:%(levelname)s %(message)s 5 | #THUMBOR_LOG_FORMAT = '%(asctime)s %(name)s:%(levelname)s %(message)s' 6 | 7 | ## Date Format to be used by thumbor when writing log messages. 8 | ## Defaults to: %Y-%m-%d %H:%M:%S 9 | #THUMBOR_LOG_DATE_FORMAT = '%Y-%m-%d %H:%M:%S' 10 | 11 | ################################################################################ 12 | 13 | 14 | ################################### Imaging #################################### 15 | 16 | ## Max width in pixels for images read or generated by thumbor 17 | ## Defaults to: 0 18 | #MAX_WIDTH = 0 19 | 20 | ## Max height in pixels for images read or generated by thumbor 21 | ## Defaults to: 0 22 | #MAX_HEIGHT = 0 23 | 24 | ## Min width in pixels for images read or generated by thumbor 25 | ## Defaults to: 1 26 | #MIN_WIDTH = 1 27 | 28 | ## Min width in pixels for images read or generated by thumbor 29 | ## Defaults to: 1 30 | #MIN_HEIGHT = 1 31 | 32 | ## Allowed domains for the http loader to download. These are regular 33 | ## expressions. 34 | ## Defaults to: [] 35 | #ALLOWED_SOURCES = # [ 36 | # ] 37 | 38 | 39 | ## Quality index used for generated JPEG images 40 | ## Defaults to: 80 41 | #QUALITY = 80 42 | 43 | ## Quality index used for generated WebP images. If not set (None) the same level 44 | ## of JPEG quality will be used. 45 | ## Defaults to: None 46 | #WEBP_QUALITY = None 47 | 48 | ## Specifies whether WebP format should be used automatically if the request 49 | ## accepts it (via Accept header) 50 | ## Defaults to: False 51 | #AUTO_WEBP = False 52 | 53 | ## Max AGE sent as a header for the image served by thumbor in seconds 54 | ## Defaults to: 86400 55 | MAX_AGE = {{ thumbor_max_age }} 56 | 57 | ## Indicates the Max AGE header in seconds for temporary images (images with 58 | ## failed smart detection) 59 | ## Defaults to: 0 60 | #MAX_AGE_TEMP_IMAGE = 0 61 | 62 | ## Indicates whether thumbor should rotate images that have an Orientation EXIF 63 | ## header 64 | ## Defaults to: False 65 | #RESPECT_ORIENTATION = False 66 | 67 | ## Ignore errors during smart detections and return image as a temp image (not 68 | ## saved in result storage and with MAX_AGE_TEMP_IMAGE age) 69 | ## Defaults to: False 70 | #IGNORE_SMART_ERRORS = False 71 | 72 | ## Preserves exif information in generated images. Increases image size in 73 | ## kbytes, use with caution. 74 | ## Defaults to: False 75 | #PRESERVE_EXIF_INFO = False 76 | 77 | ## Indicates whether thumbor should enable the EXPERIMENTAL support for animated 78 | ## gifs. 79 | ## Defaults to: True 80 | #ALLOW_ANIMATED_GIFS = True 81 | 82 | ## Indicates whether thumbor should use gifsicle engine. Please note that smart 83 | ## cropping and filters are not supported for gifs using gifsicle (but won't 84 | ## give an error). 85 | ## Defaults to: False 86 | #USE_GIFSICLE_ENGINE = False 87 | 88 | ################################################################################ 89 | 90 | 91 | ################################ Extensibility ################################# 92 | 93 | ## The loader thumbor should use to load the original image. This must be the 94 | ## full name of a python module (python must be able to import it) 95 | ## Defaults to: thumbor.loaders.http_loader 96 | LOADER = '{{thumbor_loader}}' 97 | AWS_ACCESS_KEY = '{{thumbor_aws_access_key}}' 98 | AWS_SECRET_KEY = '{{thumbor_aws_secret_key}}' 99 | S3_LOADER_BUCKET = '{{thumbor_aws_loader_bucket}}' 100 | 101 | ## The file storage thumbor should use to store original images. This must be the 102 | ## full name of a python module (python must be able to import it) 103 | ## Defaults to: thumbor.storages.file_storage 104 | STORAGE = '{{thumbor_storage}}' 105 | 106 | ## The result storage thumbor should use to store generated images. This must be 107 | ## the full name of a python module (python must be able to import it) 108 | ## Defaults to: None 109 | RESULT_STORAGE = '{{thumbor_result_storage}}' 110 | 111 | ## The imaging engine thumbor should use to perform image operations. This must 112 | ## be the full name of a python module (python must be able to import it) 113 | ## Defaults to: thumbor.engines.pil 114 | #ENGINE = 'thumbor.engines.pil' 115 | 116 | ################################################################################ 117 | 118 | 119 | ################################### Security ################################### 120 | 121 | ## The security key thumbor uses to sign image URLs 122 | ## Defaults to: MY_SECURE_KEY 123 | #SECURITY_KEY = 'MY_SECURE_KEY' 124 | 125 | ## Indicates if the /unsafe URL should be available 126 | ## Defaults to: True 127 | #ALLOW_UNSAFE_URL = True 128 | 129 | ## Indicates if encrypted (old style) URLs should be allowed 130 | ## Defaults to: True 131 | #ALLOW_OLD_URLS = True 132 | 133 | ################################################################################ 134 | 135 | 136 | ################################# File Loader ################################## 137 | 138 | ## The root path where the File Loader will try to find images 139 | ## Defaults to: /tmp 140 | #FILE_LOADER_ROOT_PATH = '/tmp' 141 | 142 | ################################################################################ 143 | 144 | 145 | ################################# HTTP Loader ################################## 146 | 147 | ## The maximum number of seconds libcurl can take to connect to an image being 148 | ## loaded 149 | ## Defaults to: 5 150 | #HTTP_LOADER_CONNECT_TIMEOUT = 5 151 | 152 | ## The maximum number of seconds libcurl can take to download an image 153 | ## Defaults to: 20 154 | #HTTP_LOADER_REQUEST_TIMEOUT = 20 155 | 156 | ## Indicates whether libcurl should follow redirects when downloading an image 157 | ## Defaults to: True 158 | #HTTP_LOADER_FOLLOW_REDIRECTS = True 159 | 160 | ## Indicates the number of redirects libcurl should follow when downloading an 161 | ## image 162 | ## Defaults to: 5 163 | #HTTP_LOADER_MAX_REDIRECTS = 5 164 | 165 | ## Indicates whether thumbor should forward the user agent of the requesting user 166 | ## Defaults to: False 167 | #HTTP_LOADER_FORWARD_USER_AGENT = False 168 | 169 | ## Default user agent for thumbor http loader requests 170 | ## Defaults to: Thumbor/4.4.1 171 | #HTTP_LOADER_DEFAULT_USER_AGENT = 'Thumbor/4.4.1' 172 | 173 | ## The proxy host needed to load images through 174 | ## Defaults to: None 175 | #HTTP_LOADER_PROXY_HOST = None 176 | 177 | ## The proxy port for the proxy host 178 | ## Defaults to: None 179 | #HTTP_LOADER_PROXY_PORT = None 180 | 181 | ## The proxy username for the proxy host 182 | ## Defaults to: None 183 | #HTTP_LOADER_PROXY_USERNAME = None 184 | 185 | ## The proxy password for the proxy host 186 | ## Defaults to: None 187 | #HTTP_LOADER_PROXY_PASSWORD = None 188 | 189 | ################################################################################ 190 | 191 | 192 | ################################# File Storage ################################# 193 | 194 | ## Expiration in seconds for the images in the File Storage. Defaults to one 195 | ## month 196 | ## Defaults to: 2592000 197 | #STORAGE_EXPIRATION_SECONDS = 2592000 198 | 199 | ## Indicates whether thumbor should store the signing key for each image in the 200 | ## file storage. This allows the key to be changed and old images to still be 201 | ## properly found 202 | ## Defaults to: False 203 | #STORES_CRYPTO_KEY_FOR_EACH_IMAGE = False 204 | 205 | ## The root path where the File Storage will try to find images 206 | ## Defaults to: /tmp/thumbor/storage 207 | #FILE_STORAGE_ROOT_PATH = '/tmp/thumbor/storage' 208 | 209 | ################################################################################ 210 | 211 | 212 | #################################### Upload #################################### 213 | 214 | ## Max size in Kb for images uploaded to thumbor 215 | ## Aliases: MAX_SIZE 216 | ## Defaults to: 0 217 | #UPLOAD_MAX_SIZE = 0 218 | 219 | ## Indicates whether thumbor should enable File uploads 220 | ## Aliases: ENABLE_ORIGINAL_PHOTO_UPLOAD 221 | ## Defaults to: False 222 | #UPLOAD_ENABLED = False 223 | 224 | ## The type of storage to store uploaded images with 225 | ## Aliases: ORIGINAL_PHOTO_STORAGE 226 | ## Defaults to: thumbor.storages.file_storage 227 | #UPLOAD_PHOTO_STORAGE = 'thumbor.storages.file_storage' 228 | 229 | ## Indicates whether image deletion should be allowed 230 | ## Aliases: ALLOW_ORIGINAL_PHOTO_DELETION 231 | ## Defaults to: False 232 | #UPLOAD_DELETE_ALLOWED = False 233 | 234 | ## Indicates whether image overwrite should be allowed 235 | ## Aliases: ALLOW_ORIGINAL_PHOTO_PUTTING 236 | ## Defaults to: False 237 | #UPLOAD_PUT_ALLOWED = False 238 | 239 | ## Default filename for image uploaded 240 | ## Defaults to: image 241 | #UPLOAD_DEFAULT_FILENAME = 'image' 242 | 243 | ################################################################################ 244 | 245 | 246 | ############################### MongoDB Storage ################################ 247 | 248 | ## MongoDB storage server host 249 | ## Defaults to: localhost 250 | #MONGO_STORAGE_SERVER_HOST = 'localhost' 251 | 252 | ## MongoDB storage server port 253 | ## Defaults to: 27017 254 | #MONGO_STORAGE_SERVER_PORT = 27017 255 | 256 | ## MongoDB storage server database name 257 | ## Defaults to: thumbor 258 | #MONGO_STORAGE_SERVER_DB = 'thumbor' 259 | 260 | ## MongoDB storage image collection 261 | ## Defaults to: images 262 | #MONGO_STORAGE_SERVER_COLLECTION = 'images' 263 | 264 | ################################################################################ 265 | 266 | 267 | ################################ Redis Storage ################################# 268 | 269 | ## Redis storage server host 270 | ## Defaults to: localhost 271 | #REDIS_STORAGE_SERVER_HOST = 'localhost' 272 | 273 | ## Redis storage server port 274 | ## Defaults to: 6379 275 | #REDIS_STORAGE_SERVER_PORT = 6379 276 | 277 | ## Redis storage database index 278 | ## Defaults to: 0 279 | #REDIS_STORAGE_SERVER_DB = 0 280 | 281 | ## Redis storage server password 282 | ## Defaults to: None 283 | #REDIS_STORAGE_SERVER_PASSWORD = None 284 | 285 | ################################################################################ 286 | 287 | 288 | ############################### Memcache Storage ############################### 289 | 290 | ## List of Memcache storage server hosts 291 | ## Defaults to: ['localhost:11211'] 292 | #MEMCACHE_STORAGE_SERVERS = # [ 293 | # 'localhost:11211', 294 | # ] 295 | 296 | 297 | ################################################################################ 298 | 299 | 300 | ################################ Mixed Storage ################################# 301 | 302 | ## Mixed Storage file storage. This must be the full name of a python module 303 | ## (python must be able to import it) 304 | ## Defaults to: thumbor.storages.no_storage 305 | #MIXED_STORAGE_FILE_STORAGE = 'thumbor.storages.no_storage' 306 | 307 | ## Mixed Storage signing key storage. This must be the full name of a python 308 | ## module (python must be able to import it) 309 | ## Defaults to: thumbor.storages.no_storage 310 | #MIXED_STORAGE_CRYPTO_STORAGE = 'thumbor.storages.no_storage' 311 | 312 | ## Mixed Storage detector information storage. This must be the full name of a 313 | ## python module (python must be able to import it) 314 | ## Defaults to: thumbor.storages.no_storage 315 | #MIXED_STORAGE_DETECTOR_STORAGE = 'thumbor.storages.no_storage' 316 | 317 | ################################################################################ 318 | 319 | 320 | ##################################### Meta ##################################### 321 | 322 | ## The callback function name that should be used by the META route for JSONP 323 | ## access 324 | ## Defaults to: None 325 | #META_CALLBACK_NAME = None 326 | 327 | ################################################################################ 328 | 329 | 330 | ################################## Detection ################################### 331 | 332 | ## List of detectors that thumbor should use to find faces and/or features. All 333 | ## of them must be full names of python modules (python must be able to import 334 | ## it) 335 | ## Defaults to: [] 336 | #DETECTORS = # [ 337 | # ] 338 | 339 | 340 | ## The cascade file that opencv will use to detect faces 341 | ## Defaults to: haarcascade_frontalface_alt.xml 342 | #FACE_DETECTOR_CASCADE_FILE = 'haarcascade_frontalface_alt.xml' 343 | 344 | ################################################################################ 345 | 346 | 347 | ################################### Filters #################################### 348 | 349 | ## List of filters that thumbor will allow to be used in generated images. All of 350 | ## them must be full names of python modules (python must be able to import 351 | ## it) 352 | ## Defaults to: ['thumbor.filters.brightness', 'thumbor.filters.contrast', 'thumbor.filters.rgb', 'thumbor.filters.round_corner', 'thumbor.filters.quality', 'thumbor.filters.noise', 'thumbor.filters.watermark', 'thumbor.filters.equalize', 'thumbor.filters.fill', 'thumbor.filters.sharpen', 'thumbor.filters.strip_icc', 'thumbor.filters.frame', 'thumbor.filters.grayscale', 'thumbor.filters.rotate', 'thumbor.filters.format', 'thumbor.filters.max_bytes', 'thumbor.filters.convolution', 'thumbor.filters.blur', 'thumbor.filters.extract_focal', 'thumbor.filters.no_upscale'] 353 | #FILTERS = # [ 354 | # 'thumbor.filters.brightness', 355 | # 'thumbor.filters.contrast', 356 | # 'thumbor.filters.rgb', 357 | # 'thumbor.filters.round_corner', 358 | # 'thumbor.filters.quality', 359 | # 'thumbor.filters.noise', 360 | # 'thumbor.filters.watermark', 361 | # 'thumbor.filters.equalize', 362 | # 'thumbor.filters.fill', 363 | # 'thumbor.filters.sharpen', 364 | # 'thumbor.filters.strip_icc', 365 | # 'thumbor.filters.frame', 366 | # 'thumbor.filters.grayscale', 367 | # 'thumbor.filters.rotate', 368 | # 'thumbor.filters.format', 369 | # 'thumbor.filters.max_bytes', 370 | # 'thumbor.filters.convolution', 371 | # 'thumbor.filters.blur', 372 | # 'thumbor.filters.extract_focal', 373 | # 'thumbor.filters.no_upscale', 374 | # ] 375 | 376 | 377 | ################################################################################ 378 | 379 | 380 | ################################ Result Storage ################################ 381 | 382 | ## Expiration in seconds of generated images in the result storage 383 | ## Defaults to: 0 384 | #RESULT_STORAGE_EXPIRATION_SECONDS = 0 385 | 386 | ## Path where the Result storage will store generated images 387 | ## Defaults to: /tmp/thumbor/result_storage 388 | #RESULT_STORAGE_FILE_STORAGE_ROOT_PATH = '/tmp/thumbor/result_storage' 389 | 390 | ## Indicates whether unsafe requests should also be stored in the Result Storage 391 | ## Defaults to: False 392 | #RESULT_STORAGE_STORES_UNSAFE = False 393 | 394 | ################################################################################ 395 | 396 | 397 | ############################ Queued Redis Detector ############################# 398 | 399 | ## Server host for the queued redis detector 400 | ## Defaults to: localhost 401 | #REDIS_QUEUE_SERVER_HOST = 'localhost' 402 | 403 | ## Server port for the queued redis detector 404 | ## Defaults to: 6379 405 | #REDIS_QUEUE_SERVER_PORT = 6379 406 | 407 | ## Server database index for the queued redis detector 408 | ## Defaults to: 0 409 | #REDIS_QUEUE_SERVER_DB = 0 410 | 411 | ## Server password for the queued redis detector 412 | ## Defaults to: None 413 | #REDIS_QUEUE_SERVER_PASSWORD = None 414 | 415 | ################################################################################ 416 | 417 | 418 | ############################# Queued SQS Detector ############################## 419 | 420 | ## AWS key id 421 | ## Defaults to: None 422 | #SQS_QUEUE_KEY_ID = None 423 | 424 | ## AWS key secret 425 | ## Defaults to: None 426 | #SQS_QUEUE_KEY_SECRET = None 427 | 428 | ## AWS SQS region 429 | ## Defaults to: us-east-1 430 | #SQS_QUEUE_REGION = 'us-east-1' 431 | 432 | ################################################################################ 433 | 434 | 435 | #################################### Errors #################################### 436 | 437 | ## This configuration indicates whether thumbor should use a custom error 438 | ## handler. 439 | ## Defaults to: False 440 | #USE_CUSTOM_ERROR_HANDLING = False 441 | 442 | ## Error reporting module. Needs to contain a class called ErrorHandler with a 443 | ## handle_error(context, handler, exception) method. 444 | ## Defaults to: thumbor.error_handlers.sentry 445 | #ERROR_HANDLER_MODULE = 'thumbor.error_handlers.sentry' 446 | 447 | ## File of error log as json 448 | ## Defaults to: None 449 | #ERROR_FILE_LOGGER = None 450 | 451 | ## File of error log name is parametrized with context attribute 452 | ## Defaults to: False 453 | #ERROR_FILE_NAME_USE_CONTEXT = False 454 | 455 | ################################################################################ 456 | 457 | 458 | ############################### Errors - Sentry ################################ 459 | 460 | ## Sentry thumbor project dsn. i.e.: http://5a63d58ae7b94f1dab3dee740b301d6a:73ee 461 | ## a45d3e8649239a973087e8f21f98@localhost:9000/2 462 | ## Defaults to: 463 | #SENTRY_DSN_URL = '' 464 | 465 | ################################################################################ 466 | --------------------------------------------------------------------------------