nginx服务器无法显示来自后端的图像

时间:2018-09-11 09:20:50

标签: php postgresql nginx centos brokenimage

一个网站停止显示图像(显示断开的图像链接)。

有两个事实:

但是,如果我将此链接复制到Web浏览器,则在Mozilla的情况下,我会看到“由于包含错误而无法显示该图像”。

事实三:

  • 如果我在localhost上的apache2(背面和正面)下启动此网站的副本,则图像会正确显示。所以这就是为什么我倾向于认为问题出在nginx中。

事实四:

  • 这里还有其他信息,例如文本,也来自后端。

有什么建议吗?

UPD。显示新闻的代码(每个新闻都有图片)

<?php
$datalayer = new \DataLayer\DataLayer();
$page = array_key_exists('page', $parameters) ? $parameters['page'] : 1;
$count = array_key_exists('count', $parameters) ? $parameters['count'] : 8;
$request = new \DataLayer\Main\Requests\GetNews($page, $count);
$type = array_key_exists('type', $parameters) ? $parameters['type'] : 'horizontal';

$news = $datalayer->processRequest('getNews', $request)['data'];
?>


<div class="news8 <?=($news->Page == $news->TotalPages ? " last" : "")?>">
  <?php foreach($news->News as $key => $row): ?>
  <a class="container" href="/?news=<?=$row->Id?>">
      <img class="header-image" src="<?=($row->Image ? './?image='.$row->Image.'&size=preview' : './media/imgs/ico-no-img.png')?>" />
      <div class="news-info">
          <div class="news-header"><?=$row->Title?></div>
          <div class="news-date"><?=date ("d.m.Y", time($row->Created))?></div>
      </div>
  </a>
  <?php endforeach; ?>

配置

ssl.conf
#
# HTTPS server configuration
#

server {
     listen       443 ssl http2 default_server;

     server_name  www.hostname.example;
     root         /path/to/root;
     index       index.php index.html;

     ssl_certificate hostname_example.crt;
     ssl_certificate_key  hostname_example.key;

     ssl_session_cache shared:SSL:1m;
     ssl_session_timeout  10m;
     ssl_ciphers HIGH:!aNULL:!MD5;
     ssl_prefer_server_ciphers on;

     # Load configuration files for the default server block.
     include /etc/nginx/default.d/*.conf;

     location / {
     }

     error_page 404 /404.html;
         location = /40x.html {
     }

     error_page 500 502 503 504 /50x.html;
          location = /50x.html {
     }

     location ~ \.php$ {
         fastcgi_cache  portalName;
         fastcgi_cache_valid 200 301 302 304 60m;
         fastcgi_cache_key "$request_method$http_if_modified_since$http_if_none_match$host$request_uri";
         fastcgi_pass_header "X-Accel-Expires";    
         fastcgi_pass 127.0.0.1:9000;
         fastcgi_index index.php;
         fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
         fastcgi_param HTTP_IF_NONE_MATCH $http_if_none_match;
         fastcgi_param HTTP_IF_MODIFIED_SINCE $http_if_modified_since;
         fastcgi_param HTTP_X_REAL_IP $remote_addr;
         include        fastcgi_params;
     }
}

0 个答案:

没有答案