server { listen 80; listen [::]:80; server_name ~.; rewrite ^/(.*)/$ /$1 permanent; # truncate forward slash root /var/www/josh; error_page 404 /static/error/404.html; location = /static/error/404.html {} location = / { index index.html; } location = /favicon.ico { try_files /static/favicon.ico =404; } location / { try_files $uri $uri.xml $uri.html =404; } location = /resume { rewrite /resume /static/resume.pdf; } location = /josh.gpg { rewrite /josh.gpg /static/josh.gpg; } location ~ /static/(.*) { try_files $uri $uri.html @s3static; } set $bucket "joshstock.in/static"; location @s3static { proxy_intercept_errors on; proxy_redirect off; add_header Cache-Control max-age=31536000; proxy_pass https://$bucket/$1; } }