diff --git a/resources/giphy-proxy.conf b/resources/giphy-proxy.conf new file mode 100644 index 000000000..c4fdb03e7 --- /dev/null +++ b/resources/giphy-proxy.conf @@ -0,0 +1,53 @@ +server { + listen 443 ssl; + + server_name giphy-proxy.example.com; + + ssl_certificate /etc/nginx/ssl/giphy-proxy.example.com.crt; + ssl_certificate_key /etc/nginx/ssl/giphy-proxy.example.com.key; + + ssl_stapling on; + ssl_stapling_verify on; + resolver 8.8.4.4 8.8.8.8 valid=300s; + resolver_timeout 10s; + + location / { + if ($request_method = 'OPTIONS') { + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range'; + + add_header 'Access-Control-Max-Age' 1728000; + add_header 'Content-Type' 'text/plain; charset=utf-8'; + add_header 'Content-Length' 0; + return 204; + } + if ($request_method = 'POST') { + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range'; + add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range'; + } + if ($request_method = 'GET') { + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range'; + add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range'; + } + + root /usr/share/nginx/html; + index index.html index.htm; + } + + location /gifs/trending { + proxy_pass https://api.giphy.com/v1/gifs/trending; + } + + location /gifs/search { + proxy_pass https://api.giphy.com/v1/gifs/search; + } + + location ~ /gifs/id/(.*) { + proxy_pass https://i.giphy.com/media/$1/giphy.gif; + } +}