server { listen 80; server_name {{ env "DOMAIN" }}; root /usr/share/nginx/website; index index.html; location / { {{ if eq (env "AUTH_SITE_ENABLED") "1" }} auth_basic "Site access restricted"; auth_basic_user_file /etc/nginx/.htpasswd; {{ end }} try_files $uri $uri/index.html =404; } # Media: images, icons, video, audio, HTC location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|mp3|ogg|ogv|webm|htc)$ { expires 1M; access_log off; # max-age must be in seconds add_header Cache-Control "max-age=2629746, public"; } # CSS and Javascript location ~* \.(?:css|js|ttf|otf|woff2|woff)$ { expires 1y; access_log off; add_header Cache-Control "max-age=31556952, public"; } location /deploy { {{ if eq (env "AUTH_ENABLED") "1" }} auth_basic "Administrator’s Area"; auth_basic_user_file /etc/nginx/.htpasswd; {{ end }} proxy_pass http://badger:8080; } } {{ if (env "HUGO_GIT_BRANCH_STAGING") }} server { listen 80; server_name staging.{{ env "DOMAIN" }}; root /usr/share/nginx/website-staging; index index.html; location / { {{ if eq (env "AUTH_SITE_STAGING_ENABLED") "1" }} auth_basic "Site access restricted"; auth_basic_user_file /etc/nginx/.htpasswd; {{ end }} try_files $uri $uri/index.html =404; } # Media: images, icons, video, audio, HTC location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|mp3|ogg|ogv|webm|htc)$ { expires 1M; access_log off; # max-age must be in seconds add_header Cache-Control "max-age=2629746, public"; } # CSS and Javascript location ~* \.(?:css|js|ttf|otf|woff2|woff)$ { expires 1y; access_log off; add_header Cache-Control "max-age=31556952, public"; } location /deploy { {{ if eq (env "AUTH_STAGING_ENABLED") "1" }} auth_basic "Administrator’s Area"; auth_basic_user_file /etc/nginx/.htpasswd; {{ end }} proxy_pass http://badger-staging:8080; } } {{ end }}