CentOs 7 Nginx (13: доступ запрещен) при загрузке файла шрифта из css

У меня есть веб-сервер nginx с фреймворком bootstrap js. Я пытаюсь заставить css загружать файлы шрифтов. Хотя я получаю ошибку 403, когда браузер пытается получить доступ к файлам шрифтов.

Я просмотрел serverfault для тех, у кого были похожие проблемы, хотя мне не удалось применить их решения. пример: " Как я могу сделать так, чтобы nginx поддерживал форматы @ font-face и разрешал access-control-allow-origin? "

Ниже приведены моя ошибка и конфигурация моего сервера:

Ошибка:

2016/01/07 10:30:10 [error] 20770#0: *26 open() "/usr/share/nginx/html/fonts/glyphicons-halflings-regular.ttf" failed (13: Permission denied), client: 0.0.0.0, server: localhost, request: "GET /fonts/glyphicons-halflings-regular.ttf HTTP/1.1", host: "localhost", referrer: "http://localhost/css/bootstrap.min.css"

/etc/nginx/conf.d/default.conf:

server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;

        if ($request_filename ~* ^.*?/([^/]*?)$)
            {
                set $filename $1;
            }

        if ($filename ~* ^.*?\.(eot)|(ttf)|(woff)$){
                add_header Access-Control-Allow-Origin *;
           }
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    location ~ \.php$ {
        root           /usr/share/nginx/html;
        try_files $uri =404;
        fastcgi_pass   unix:/var/run/php-fpm/php5-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }


    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
     #
    location ~ /\.ht {
        deny  all;
    }
}

/etc/nginx/mime.types:

application/vnd.ms-fontobject         eot;
    application/font-sfnt                 otf ttf;
    application/font-woff                 woff;
    application/font-woff2                woff2;

systemctl перезапустить nginx. service

0
задан 13 April 2017 в 15:14
1 ответ

Это nginx не может открыть файл (в отличие от nginx, запрещающего доступ сам по себе), убедитесь, что пользователю nginx разрешено читать глификоны-халфлинги.ttf

1
ответ дан 4 December 2019 в 16:39

Теги

Похожие вопросы