使用Nginx,我從XAMPP切換到Docker,現在我的css文件在XAMPP工作得很好,但在這里卻不行。我在FireFox控制臺中收到的錯誤消息是:
The stylesheet was not loaded because its MIME type, “text/html”, is not “text/css”.
我試圖包含mime.types,但它不起作用。我加了外景~。css和位置~。現在我得到了:
GET http://localhost/main.css [HTTP/1.1 404 Not Found 3ms]
文件夾:
app/public
index.php
main.css
php/
Dockerfile
nginx/conf.d
default.conf
mime.types
docker-compose.yaml
docker-compose.yaml
services:
web:
image: nginx:latest
ports:
- "80:80"
volumes:
- ./nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf
app:
build:
dockerfile: ./php/Dockerfile
volumes:
- ./app:/app
默認. conf.d
server {
include mime.types;
listen 80;
server_name localhost;
root /app/public;
index index.php;
location ~ \.php$ {
fastcgi_pass app:9000;
fastcgi_index index.php;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.css {
add_header Content-Type text/css;
}
location ~ \.js {
add_header Content-Type application/x-javascript;
}
}
mime.types
types {
text/html html htm shtml;
text/css css;
text/xml xml rss;
image/gif gif;
image/jpeg jpeg jpg;
application/x-javascript js;
text/plain txt;
text/x-component htc;
text/mathml mml;
image/png png;
image/x-icon ico;
image/x-jng jng;
image/vnd.wap.wbmp wbmp;
application/java-archive jar war ear;
application/mac-binhex40 hqx;
application/pdf pdf;
application/x-cocoa cco;
application/x-java-archive-diff jardiff;
application/x-java-jnlp-file jnlp;
application/x-makeself run;
application/x-perl pl pm;
application/x-pilot prc pdb;
application/x-rar-compressed rar;
application/x-redhat-package-manager rpm;
application/x-sea sea;
application/x-shockwave-flash swf;
application/x-stuffit sit;
application/x-tcl tcl tk;
application/x-x509-ca-cert der pem crt;
application/x-xpinstall xpi;
application/zip zip;
application/octet-stream deb;
application/octet-stream bin exe dll;
application/octet-stream dmg;
application/octet-stream eot;
application/octet-stream iso img;
application/octet-stream msi msp msm;
audio/mpeg mp3;
audio/x-realaudio ra;
video/mpeg mpeg mpg;
video/quicktime mov;
video/x-flv flv;
video/x-msvideo avi;
video/x-ms-wmv wmv;
video/x-ms-asf asx asf;
video/x-mng mng;
}
上一篇c# 傳送json數據
下一篇vue 獲取滾動距離