0

I've configured Nginx as you can see:

server {

    listen 443 ssl;
    ssl on;
    ssl_certificate /etc/nginx/ssl/bundle.crt;
    ssl_certificate_key /etc/nginx/ssl/privateKey.key;

    location /webmin/ {
            proxy_pass http://127.0.0.1:10000;
    }

server {

    listen 80;
    listen 443 ssl;
    ssl_certificate /etc/nginx/ssl/bundle.crt;
    ssl_certificate_key /etc/nginx/ssl/privateKey.key;
    server_name localjob.it;
    access_log off;

    location / {
          alias /webapps/sitoweb/;
    }

Now if I go on mysite.com the page is loaded with the CSS, but if I add:

    location ~* \.(css|js|gif|jpe?g|png)$ {
          expires 168h;
          add_header Pragma public;
          add_header Cache-Control "public, must-revalidate, proxy-revalidate";
    }

Now if I go on mysite.com the page can't load CSS. I can't understand the reason!!

ddtnero
  • 37
  • 1
  • 1
  • 4

1 Answers1

2

Nginx locations exclusive so your alias inslide root location doesn't applies to another locations. Also it's a bit misuse, just use root directive in server block.

server {
    listen 80;
    listen 443 ssl;
    ssl_certificate /etc/nginx/ssl/bundle.crt;
    ssl_certificate_key /etc/nginx/ssl/privateKey.key;
    server_name localjob.it;
    access_log off;

    root /webapps/sitoweb;

    location ~* \.(css|js|gif|jpe?g|png)$ {
          expires 168h;
          add_header Pragma public;
          add_header Cache-Control "public, must-revalidate, proxy-revalidate";
    }
}
Alexey Ten
  • 13,794
  • 6
  • 44
  • 54
  • It work but I've another question. I've added another location like this in the same server declaration: `location /django/ { proxy_pass http://127.0.0.1:8001; proxy_set_header X-Forwarded-Host $server_name; proxy_set_header X-Real-IP $remote_addr; add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"'; add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Headers' 'Content-Type,Accept'; }` Now the all the css in my web site is loaded except the css located in /django/ like www.mysite.com/django/myfile.css – ddtnero Sep 05 '14 at 12:48