feat(giphy) add sample resource for giphy-proxy

This commit is contained in:
Mihaela Dumitru 2023-02-02 11:08:40 +02:00 committed by Saúl Ibarra Corretgé
parent bf1b7cc856
commit f95e167779
1 changed files with 53 additions and 0 deletions

View File

@ -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;
}
}