├── Dockerfile ├── README.md └── nginx.conf /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nginx 2 | 3 | RUN rm /etc/nginx/conf.d/*.conf 4 | 5 | ADD nginx.conf /etc/nginx/nginx.conf 6 | 7 | RUN mkdir -p /data/nginx/cache 8 | 9 | VOLUME /data/nginx/cache 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # nginx-external-service-proxy 2 | 3 | A basic reverse proxy so you don't have to hit external services multiple times for both speed and cost. 4 | 5 | You can start it with Docker using: 6 | 7 | docker run -d -p 80:8080 -v /data/nginx/cache:/data/nginx/cache state/nginx-external-service-proxy:latest 8 | -------------------------------------------------------------------------------- /nginx.conf: -------------------------------------------------------------------------------- 1 | worker_processes 1; 2 | 3 | events { 4 | worker_connections 1024; 5 | } 6 | 7 | error_log /dev/stdout debug; 8 | 9 | http { 10 | proxy_cache_path /data/nginx/cache levels=1:2 keys_zone=one:10m; 11 | 12 | log_format cache_status '[$time_local] "$request" $upstream_cache_status'; 13 | access_log /dev/stdout cache_status; 14 | 15 | 16 | server { 17 | listen 8080; 18 | server_name access.alchemyapi.com, api.embed.ly; 19 | resolver 8.8.8.8; 20 | 21 | location / { 22 | proxy_cache one; 23 | proxy_cache_methods GET HEAD POST; 24 | 25 | proxy_cache_valid 10080m; 26 | proxy_ignore_headers "Cache-Control"; 27 | proxy_cache_key $request_uri$request_body; 28 | 29 | proxy_buffers 8 32k; 30 | proxy_buffer_size 64k; 31 | 32 | proxy_pass http://$http_host$uri$is_args$args; 33 | 34 | add_header X-Cached $upstream_cache_status; 35 | } 36 | } 37 | } 38 | --------------------------------------------------------------------------------