From a744d92ba1f1f78e262cc3f5e39ea21007fa603e Mon Sep 17 00:00:00 2001 From: Johannes Schickling Date: Mon, 30 Nov 2015 14:28:51 +0000 Subject: [PATCH] thumbor-nginx-cors --- README.md | 1 + thumbor-nginx-cors/Dockerfile | 4 ++ thumbor-nginx-cors/README.md | 3 ++ thumbor-nginx-cors/nginx.conf | 75 +++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+) create mode 100644 thumbor-nginx-cors/Dockerfile create mode 100644 thumbor-nginx-cors/README.md create mode 100644 thumbor-nginx-cors/nginx.conf diff --git a/README.md b/README.md index ee03e62..b08518e 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ Collection of lightweight and ready-to-use docker images * **[Rust](https://github.com/schickling/dockerfiles/tree/master/rust)** - Lightweight nightly Rust build including Cargo and GDB * **[swagger-ui](https://github.com/schickling/dockerfiles/tree/master/swagger-ui)** - Swagger UI 2.1.2 with API_URL and API_KEY injection (45 MB) * **[s3cmd](https://github.com/schickling/dockerfiles/tree/master/s3cmd)** - Lightweight wrapper around s3cmd +* **[thumbor-nginx-cors](https://github.com/schickling/dockerfiles/tree/master/thumbor-nginx-cors)** - Nginx image for thumbor with CORS support ## FAQ diff --git a/thumbor-nginx-cors/Dockerfile b/thumbor-nginx-cors/Dockerfile new file mode 100644 index 0000000..53740cb --- /dev/null +++ b/thumbor-nginx-cors/Dockerfile @@ -0,0 +1,4 @@ +FROM nginx:1.9 +MAINTAINER Johannes Schickling "schickling.j@gmail.com" + +COPY nginx.conf /etc/nginx/ diff --git a/thumbor-nginx-cors/README.md b/thumbor-nginx-cors/README.md new file mode 100644 index 0000000..5fea3d6 --- /dev/null +++ b/thumbor-nginx-cors/README.md @@ -0,0 +1,3 @@ +# thumbor-nginx-cors + +Nginx image for thumbor with CORS support (based on [APSL/docker-thumbor](https://github.com/APSL/docker-thumbor)) diff --git a/thumbor-nginx-cors/nginx.conf b/thumbor-nginx-cors/nginx.conf new file mode 100644 index 0000000..34bb977 --- /dev/null +++ b/thumbor-nginx-cors/nginx.conf @@ -0,0 +1,75 @@ +user nginx; +worker_processes 1; +pid /var/run/nginx.pid; + +events { + worker_connections 1024; + # multi_accept on; +} + +http { + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + types_hash_max_size 2048; + server_tokens off; + port_in_redirect on; + + server_names_hash_bucket_size 128; + server_name_in_redirect off; + + client_max_body_size 60m; + + include /etc/nginx/mime.types; + default_type application/octet-stream; + + send_timeout 300; + client_body_timeout 300; + client_header_timeout 300; + + access_log /logs/access.log; + error_log /logs/error.log; + + 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/x-javascript text/xml application/xml application/xml+rss text/javascript; + + upstream thumbor { + server thumbor:80; + } + + server { + listen 80 default; + server_name localhost; + + add_header 'Access-Control-Allow-Origin' "$http_origin"; + add_header 'Access-Control-Allow-Credentials' 'true'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With'; + + if ($request_method = 'OPTIONS') { + return 204; + } + + location ~* "^/(..)(..)(.+)?$" { + root /data/result_storage/v2/$1/$2; + expires 1M; + error_page 404 = @fetch; + } + + location @fetch { + internal; + proxy_pass http://thumbor$request_uri; + } + + location ~ /\.ht { deny all; } + location ~ /\.hg { deny all; } + location ~ /\.svn { deny all; } + } +}