Nginx finds css but does not load it in index.html

my nginx server serves for the index.html file, which loads the css file and some js files. The css file is loaded (NO 404), but the style is not displayed.

folders:

/src
    /assets
        /images
            ...
        /sounds
            ...
    /css
        /style.css
    /js
        ...
    index.html

sound and images downloaded by js files work fine.

/ etc / nginx / sites-enabled / default /:

server {
  listen 8080;
  server_name jumpnrun jumpnrun.vm;
  access_log /var/log/nginx/jumpnrun.access.log;
  error_log /var/log/nginx/jumpnrun.error.log;

  location / {
    try_files $uri $uri/index.html;
  }

  location ~ ^/(assets/|css/|js/|index.html) {
    root /src;
    index index.html;
    access_log off;
  }

  location /socket.io {
    add_header Access-Control-Allow-Origin *;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;
    proxy_http_version 1.1;
    proxy_pass http://node-server;
  }

}

index.html:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <title>Jump n' Run</title>
        <link href="css/style.css" type="text/css" rel="stylesheet" />
    </head>
    <body>
        <canvas id="game" width='1000' height='500'></canvas>
        <button class="sound"></button>
    </body>
    <!-- JS -->
</html>

if I go to localhost: 8080 it gives me an index page, but without any style, and the dev tools show me no errors.

thank you for your help!

EDIT

It's all about the docker container. Now every time I look at localhost: 8080 nginx dies. the error log is somehow unavailable.

+4
source share
2 answers

, , http nginx.conf mime.types :

http { 
    include /etc/nginx/mime.types;
}
+4

@charset "UTF-8";

css . , .

0

All Articles