Welcome! Log In Create A New Profile


cannot load mime types and images in nginx

Posted by chrisguk 
cannot load mime types and images in nginx
February 05, 2020 04:00AM
I am trying to load static files as detailed below. The index.html loads but all the other content for example .json, .css and .jpg files are not loading.

Here is my config:

server {
listen 80 default_server;
return 301 https://$host$request_uri;
#oot /var/www/site/public/client/;
server_name site.mydomain.net;
return 444;

server {
listen 443 ssl http2 default_server;
server_name _;
index index.html index.php;

# standard includes
include conf.d/directive-only/ssl.conf;
include conf.d/basic.conf;

location ^~ /site/client/ {
alias /var/www/site/public/client/;
include conf.d/services/php7.conf;
#index index.html;

location ~* ^.+/\.(?:css|js|json|txt)$ {
try_files $uri *.json
expires 1y;
access_log off;
add_header Cache-Control "public";


#rss feeds and atom
location ~* \.(?:rss|atom)$ {
expires 1h;
add_header Cache-Control "public";

# Media: images, icons, video, audio, HTC
location ~* ^.+/\.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
expires 1M;
access_log off;
add_header Cache-Control "public";

location /site/ {
alias /var/www/site/public/;

fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/site/public/index.php;


# misc standard nginx configs
location = /basic_status {
stub_status on;
access_log off;
include conf.d/whitelists/internal.conf;
deny all;

location ~ index\.html$ {
etag off;
add_header "Cache-Control" "max-age=0, no-cache, no-store, must-revalidate";
add_header "Pragma" "no-cache";
add_header "Expires" "Wed, 11 Jan 1984 05:00:00 GMT";

location ~ /\. {
access_log off;
log_not_found off;
deny all;

The one that is not loading the extra mime.types or images or json etc is this location block:

location ^~ /site/client/

The location of the other file types are in the following directory:


The errors I am getting are:

nginx errorlog:

2020/02/04 21:47:18 [error] 6#6: *179 open() "/etc/nginx/html/client/assets/images/james.png" failed (2: No such file or directory), client:, server: site.mydomain.net, request: "GET /client/assets/images/james.png HTTP/1.0", host: "site.mydomain.net", referrer: "https://site.mydomain.net/james/client/"

I have checked all the permissions and it is all correct.

Is this enough information to make a suggestion for a fix?
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 64
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready