diff --git a/.gitignore b/.gitignore index f10670317..08540289b 100755 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,6 @@ node_modules .vscode *.env Resources/nginx/ssl/* -!Resources/nginx/ssl/*.sample.* +!Resources/nginx/ssl/*.prod.* .idea* data/v2/manifest.json* diff --git a/Resources/gcp/create_gql_vm.sh b/Resources/gcp/create_gql_vm.sh index 85bc3b80e..c659213d9 100644 --- a/Resources/gcp/create_gql_vm.sh +++ b/Resources/gcp/create_gql_vm.sh @@ -8,10 +8,14 @@ gcloud compute instances create graphql \ --boot-disk-size=20GB \ --boot-disk-type=pd-standard \ --network-interface=network=default,subnet=default \ - --tags=http-server,https-server \ + --tags=https-server \ --metadata=startup-script='#!/bin/bash set -euo pipefail +if [ -f /root/done ]; then + exit 0 +fi + if [ ! -f /swapfile ]; then fallocate -l 1G /swapfile || dd if=/dev/zero of=/swapfile bs=1M count=1024 chmod 600 /swapfile @@ -22,7 +26,7 @@ fi # Update and install prerequisite packages apt-get update -apt-get install -y ca-certificates curl gnupg +apt-get install -y ca-certificates curl gnupg make # Add Docker official GPG key and repository install -m 0755 -d /etc/apt/keyrings @@ -43,5 +47,19 @@ if [ ! -d /root/pokeapi ]; then git clone https://github.com/PokeAPI/pokeapi.git /root/pokeapi fi -touch /tmp/done +curl -L https://raw.githubusercontent.com/hasura/graphql-engine/refs/heads/master/cli/get.sh | bash + +cp /root/pokeapi/Resources/nginx/ssl/cache.prod.conf /root/pokeapi/Resources/nginx/ssl/cache.conf +cp /root/pokeapi/Resources/nginx/ssl/ssl.prod.conf /root/pokeapi/Resources/nginx/ssl/ssl.conf + +touch /root/done + +# cd pokeapi +# vi .env # POSTGRES_PASSWORD HASURA_GRAPHQL_ADMIN_SECRET +# vi Resources/nginx/ssl/cert.cer # With CF gneerated certificate +# vi Resources/nginx/ssl/key.key +# set -a && source .env && set +a +# make start-graphql-prod +# make update-graphql-data-prod +# Update DNS A record on CF with new IP address ' diff --git a/Resources/nginx/nginx-gql-v1beta.conf b/Resources/nginx/nginx-gql-v1beta.conf index 26289e4fa..efc8c2867 100644 --- a/Resources/nginx/nginx-gql-v1beta.conf +++ b/Resources/nginx/nginx-gql-v1beta.conf @@ -1,3 +1,5 @@ +# Deprecated v1beta + worker_processes 1; events { diff --git a/Resources/nginx/nginx.conf b/Resources/nginx/nginx.conf index 8a60cbf6b..6a283eb3c 100644 --- a/Resources/nginx/nginx.conf +++ b/Resources/nginx/nginx.conf @@ -41,7 +41,7 @@ http { gzip_min_length 256; gzip_types application/atom+xml application/geo+json application/javascript application/x-javascript application/json application/ld+json application/manifest+json application/rdf+xml application/rss+xml application/xhtml+xml application/xml font/eot font/otf font/ttf image/svg+xml text/css text/javascript text/plain text/xml; - resolver 127.0.0.11 valid=10s; + resolver 127.0.0.11 valid=1m; geo $limit { default 1; @@ -119,7 +119,17 @@ http { location /v1beta2 { access_log /dev/stdout pokeapilogformat if=$only_post; - include /ssl/cache.conf*; + proxy_buffer_size 16k; + proxy_buffers 8 16k; + proxy_busy_buffers_size 112k; + proxy_cache small; + proxy_cache_valid 200 10d; + proxy_cache_valid any 0; + proxy_cache_methods POST; + proxy_cache_key "$request_method$request_uri$request_body"; + proxy_cache_lock on; + add_header X-Proxy-Cache $upstream_cache_status; + add_header X-Cache-Date $upstream_http_date; limit_req zone=graphqlDefaultLimit burst=200 nodelay; limit_req_status 429; expires 30m; diff --git a/Resources/nginx/ssl/ssl.sample.conf b/Resources/nginx/ssl/ssl.prod.conf similarity index 100% rename from Resources/nginx/ssl/ssl.sample.conf rename to Resources/nginx/ssl/ssl.prod.conf