Skip to content

Commit

Permalink
Refactor Nginx configuration to include static file mapping for Brazi…
Browse files Browse the repository at this point in the history
…l Blog
  • Loading branch information
drikusroor committed Apr 15, 2024
1 parent 46fedfc commit 045775b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
1 change: 1 addition & 0 deletions docker-compose-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ services:
- ./nginx:/etc/nginx/conf.d # Your Nginx configuration files
- /etc/letsencrypt:/etc/letsencrypt # SSL certificates
- /var/www/certbot:/var/www/certbot # Let's Encrypt challenge responses
- ./src/brazil_blog/static:/usr/share/nginx/html/static # Static files
depends_on:
- brazil-blog-web
21 changes: 6 additions & 15 deletions nginx/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ server {
ssl_certificate /etc/letsencrypt/live/brazil.kokokoding.nl/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/brazil.kokokoding.nl/privkey.pem;

# Caching static assets
# location ~* \.(css|js|jpg|jpeg|png|gif|ico|svg)$ {
# expires 30d;
# add_header Cache-Control "public";
# }
location /static/ {
root ./static; # This path should lead to where your static directories are
expires 30d;
access_log off;
add_header Cache-Control "public";
}

# Dynamic content
location / {
Expand All @@ -37,14 +38,4 @@ server {
# proxy_hide_header Set-Cookie; # Ensuring no cookies for cached pages
}

# Customize caching behavior for potentially dynamic content
# location ~* ^/header/ {
# proxy_pass http://brazil-blog-web:8000;
# proxy_set_header Host $host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header X-Forwarded-Proto $scheme;
# proxy_no_cache $cookie_session; # Avoid caching if session cookie is set
# proxy_cache_bypass $cookie_session;
# }
}

0 comments on commit 045775b

Please sign in to comment.