I am trying to implement leverage browser caching for nginx. But when i insert the code inside conf file static files are not served by nginx showing 403 permission denied error.
This is my conf file
server { listen 80; server_name site.in; root /root/site-demo/; access_log /var/log/site/access_log; error_log /var/log/site/error_log; location static/ { alias /root/site-demo/static/; } location / { proxy_pass http://127.0.0.1:4000/; proxy_redirect http://127.0.0.1:4000 http://site.in; 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; } location ~* \.(?:ico|css|js|gif|jpe?g|png)$ { expires 30d; add_header Pragma public; add_header Cache-Control "public"; } }
When i remove the cache expire part everything works fine. How can i put the expires part inside location static using if condition ?
Answer
Attribution
Source : Link , Question Author : nidhinpd , Answer Author : Community