【发布时间】:2016-03-21 21:28:25
【问题描述】:
我遵循了一个教程,并在 Vagrant VM 上运行了一个 nginx 服务器(使用 Chef 作为配置器)。我只有一个 html 页面,index.html,如果我对其进行更改并运行vagrant provision,当我在浏览器中转到该页面时,更改就会反映出来。但是,我也有一个 nginx 正在服务的 css 和 js 文件,如果我对它们进行更改,即使重新加载 VM 后,这些更改也不会反映在页面上。尽管我可以通过 SSH 连接到 VM 并验证文件的较新版本确实在 VM 上,但仍然如此。我无法弄清楚虚拟机是如何访问旧文件的,因为我在进行更改时覆盖了它们。也许我的 nginx 配置文件有问题?这是:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /home/vagrant/project/webroot;
index index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
我将所有 3 个文件(js、css 和 html)文件存储在 VM 上的 webroot 中。就像我说的,我可以通过 SSH 登录并验证它们是否都在它们应该在的地方,所以我认为这一定是配置问题。我需要对 css 和 js 文件做一些特殊的事情吗?
【问题讨论】: