map $request_uri $redirect_uri { /credibility-indicators https://learn.civil.co/credibility-indicators; /about https://learn.civil.co/about; /about/ https://learn.civil.co/about; /contact https://learn.civil.co/contact; /contact/ https://learn.civil.co/contact; /constitution https://learn.civil.co/constitution; /constitution/ https://learn.civil.co/constitution; /help https://learn.civil.co/help; /help/ https://learn.civil.co/help; /our-team https://learn.civil.co/team; /our-team/ https://learn.civil.co/team; } server { listen 3000 default_server; root /usr/share/nginx/html; index index.html index.htm; 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_min_length 256; gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon; if ( $redirect_uri ) { return 301 $redirect_uri; } location / { try_files $uri @prerender; } ### force utf-8 and content type location = /.well-known/apple-developer-merchantid-domain-association { types { } default_type "text/plain;charset=utf-8"; add_header x-robots-tag "noindex, nofollow"; } location @prerender { proxy_set_header X-Prerender-Token $PRERENDER_TOKEN; set $prerender 0; if ($http_user_agent ~* "googlebot|bingbot|yandex|baiduspider|twitterbot|facebookexternalhit|rogerbot|linkedinbot|embedly|quora link preview|showyoubot|outbrain|pinterest\/0\.|pinterestbot|slackbot|vkShare|W3C_Validator") { set $prerender 1; } if ($args ~ "_escaped_fragment_") { set $prerender 1; } if ($http_user_agent ~ "Prerender") { set $prerender 0; } if ($uri ~* "\.(js|css|xml|less|png|jpg|jpeg|gif|pdf|doc|txt|ico|rss|zip|mp3|rar|exe|wmv|doc|avi|ppt|mpg|mpeg|tif|wav|mov|psd|ai|xls|mp4|m4a|swf|dat|dmg|iso|flv|m4v|torrent|ttf|woff|svg|eot)") { set $prerender 0; } #resolve using Google's DNS server to force DNS resolution and prevent caching of IPs resolver 8.8.8.8; if ($prerender = 1) { #setting prerender as a variable forces DNS resolution since nginx caches IPs and doesnt play well with load balancing set $prerender "service.prerender.io"; rewrite .* /https://$host$request_uri? break; proxy_pass https://$prerender; } if ($prerender = 0) { add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; rewrite .* /index.html break; } } location /static/ { autoindex off; alias /usr/share/nginx/html/static/; } }