【发布时间】:2022-08-16 15:03:32
【问题描述】:
当我尝试运行我的服务器(域是我的 IP 地址)时,它会加载基本 index.html,但我在我的目录中引用的所有文件(其他 CSS 文件、javascript 文件)都没有加载。
当我在 Chrome 浏览器上运行时,有趣的是,它会读取我的 index.html 文件目录中的所有 css/js 文件作为 index.html
在我的默认文件中(在 /etc/nginx/sites-enabled[available]/default 中),我的代码如下所示:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /usr/share/nginx/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name <ip-address-here>;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri /index.html;
autoindex on; (I\'ve tried with and w/o this)
# proxy_pass http://localhost:8080;
# proxy_http_version 1.1;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection \'upgrade\';
# proxy_set_header Host $host;
# proxy_cache_bypass $http_upgrade;
}
}
之前,我的文件位于名为 /srv/www/xyz.me 的文件夹中。现在我搬到了/usr/share/nginx/html。搬家前后我的问题仍然存在。
这是我第一次使用 DigitalOcean。我已经按照教程来托管我的网站和类似的东西,但我不了解 Nginx 的来龙去脉。
标签: javascript html css