diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/nginx.config b/nginx.config index a8d0880..c3588d1 100644 --- a/nginx.config +++ b/nginx.config @@ -6,18 +6,15 @@ server { return 301 https://nkode.tech$request_uri; } +# Redirect HTTP to HTTPS for nkode.tech server { - listen 443 ssl http2; - server_name www.nkode.tech; + listen 80; + server_name nkode.tech; - ssl_certificate /etc/letsencrypt/live/nkode.tech/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/nkode.tech/privkey.pem; - ssl_trusted_certificate /etc/letsencrypt/live/nkode.tech/chain.pem; - - return 301 https://nkode.tech$request_uri; + return 301 https://$host$request_uri; } -# Main server block for nkode.tech +# Main server block for nkode.tech with SSL and content configuration server { listen 443 ssl http2; server_name nkode.tech; @@ -43,12 +40,20 @@ server { add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; root /var/www/webapp; - index index.html index.htm; + index index.html; + # Routing for Flutter SPA location / { try_files $uri $uri/ /index.html; } + # Caching for Static Assets + location ~* \.(?:js|css|png|jpg|jpeg|gif|svg|ico|woff2?)$ { + expires 1y; + add_header Cache-Control "public, max-age=31536000, immutable"; + } + + # Error pages error_page 404 /404.html; location = /404.html { root /var/www/webapp; @@ -58,12 +63,9 @@ server { location = /50x.html { root /var/www/webapp; } -} -# Redirect HTTP to HTTPS for nkode.tech -server { - listen 80; - server_name nkode.tech; - - return 301 https://$host$request_uri; + # Optional: Enable Gzip Compression + gzip on; + gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; + gzip_min_length 256; }