update nginx.config

This commit is contained in:
2024-10-26 15:02:11 -05:00
parent 878af909d2
commit 20a610141d
2 changed files with 19 additions and 16 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.idea

View File

@@ -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;
}