wordpress nginx作为反向代理失败(2:没有这样的文件或目录)

bn31dyow  于 11个月前  发布在  WordPress
关注(0)|答案(1)|浏览(286)

我为许多虚拟主机设置了nginx作为反向代理,它工作得很好,但只有一个。
它正确地代理对实际服务器的调用,以及它加载一些图像和其他不.考虑到反向代理是nginx,而web服务是由apache托管.
这是error.log

2023/12/13 11:20:25 [error] 1323621#1323621: *402 open() "/usr/share/nginx/html/wp-content/uploads/2018/11/oslo.jpg" failed (2: No such file or directory), client: 192.168.49.10, server: www.my-site, request: "GET /wp-content/uploads/2018/11/oslo.jpg HTTP/1.1", host: "www.my-site", referrer: "www.my-site/"

个字符
资源存在于服务器的文件系统上,但是第一个资源被服务器找到,而第二个资源没有被服务器找到。

root@wp-02:/var/www/dstorewp02/www3/www.my-site.# ls wp-content/uploads/2022/01/flag.png 
wp-content/uploads/2022/01/flag.png
root@wp-02:/var/www/dstorewp02/www3/www.my-site.# ls wp-content/uploads/2018/11/oslo.jpg
wp-content/uploads/2018/11/oslo.jpg


在页面代码中,它们的名称如下:

<img usemap="#flags" alt="flags" src="https://www.greencharge2020.eu/wp-content/uploads/2022/01/flag.png"
            style="z-index: 5;"><img src="https://www.greencharge2020.eu/wp-content/plugins/revslider/admin/assets/images/dummy.png" alt="" data-ww="['1427px','1427px','1427px','717px']" data-hh="['855px','855px','855px','430px']" data-lazyload="https://greencharge2020.eu/wp-content/uploads/2018/11/oslo.jpg" data-no-retina> </div>


有什么提示吗?
我希望反向代理能正常工作,找到内容。

mbskvtky

mbskvtky1#

1.如果你的静态文件是在/var/www/dstorewp02/www3/www.my-site.然后告诉它使用root指令。
1.然后您必须将代理移动到指定位置@portal的门户。
1.使用location /告诉nginx尝试访问您提供的路径中的静态文件,如果文件不存在,则尝试询问@portals

root /var/www/dstorewp02/www3/www.my-site.;

location / {
  try_files $uri @portals;
}

location @portals {
    proxy_pass                          https://www.my-site.portals/; 
    proxy_set_header  Host              $http_host;
    proxy_set_header  X-Real-IP         $remote_addr;
    proxy_set_header  X-Forwarded-For   $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Host   $host:$server_port;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-Proto  $scheme;
    proxy_read_timeout                  900;
    proxy_ssl_verify                    off;
    proxy_ssl_trusted_certificate       /etc/ssl/websites/
    proxy_ssl_verify_depth              2;
    proxy_ssl_session_reuse             on;
    proxy_ssl_name                      $proxy_host;
}

字符串
1.修复从server_name gwww.my-siteserver_name www.my-site的拼写错误-因为我怀疑nginx会转到/etc/nginx/sites-enabled/default中定义的默认位置,因为它找不到www.my-site服务器块。

server {
    listen 80;
    server_name www.my-site;
    return 301 https://$server_name$request_uri;
}


或备选方案:

server {
    listen 80;
    server_name www.my-site gwww.my-site;
    return 301 https://www.my-site$request_uri;
}

相关问题