我已经配置了Nginx,如您所见:
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/;
}
现在,如果我在mysite.com上,页面会加载CSS,但如果我添加:
location ~* .(css|js|gif|jpe?g|png)$ {
expires 168h;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
现在,如果我在mysite.com上,页面无法加载CSS。我不明白原因!!
Nginx location
是独占的,因此您的别名在slide根位置不适用于另一个location
。此外,这有点误用,只需在server
块中使用root
指令即可。
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";
}
}