gpt4 book ai didi

css - 样式表在 docker 中从 nginx 提供,在页面上不可用

转载 作者:行者123 更新时间:2023-11-28 10:14:20 25 4
gpt4 key购买 nike

我在 docker 容器中运行 nginx。下面是我的 nginx.conf 文件:

worker_processes 4;

events {
worker_connections 1024;
}

http {
types {
text/css css;
}

upstream appserver {
server:3000;
}

server {
listen 80;
server_name localhost;

root /public;

try_files $uri/index.html $uri @appserver;

location @appserver {
proxy_pass http://appserver;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
}

error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
}

我的所有静态文件都在 /public 中。这个 nginx 容器后面还有另一个容器轨道。

当我执行 curl http://192.168.59.103/landing_page.css 时,我的 CSS 显示正确(192.168.59.103 是来自 boot2docker ip 的地址)。但是,当我直接访问一个页面时,CSS 是不可见的。我包括这样的样式表:

<link rel="stylesheet" type="text/css" href="/landing_page.css" />

它在 Chrome 检查器中显示如下:

Chrome inspector network tab

但是,响应是空的:

Response for the CSS file

关于要看什么的任何想法?我很难过

最佳答案

解决了。答案在这里:Nginx finds css but doesn't load it into index.html

...但是,最重要的是我遇到了一个额外的障碍:CSS 文件被缓存了,所以我必须 shift+reload 才能让它工作。

关于css - 样式表在 docker 中从 nginx 提供,在页面上不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32792413/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com