nginx 和 php-fpm 在静态内容上返回 404

nginx 和 php-fpm 在静态内容上返回 404

我正在尝试让容器 1 上的 nginx 连接到容器 2 上端口 9000 上运行 wordpress 的 php-fpm。它似乎适用于动态生成的内容(例如帖子),但静态内容(例如 CSS、JS 或图像)返回 404。这可能是什么原因造成的?

请注意,第一个“服务器”块用于捕获所有非 HTTP 请求并将其重定向到 HTTPS,而第二个块用于“捕获所有”发送“mysite.com”的请求。

谢谢你,

http {
        include       mime.types;
        default_type  application/octet-stream;
        sendfile        on;

        server {
                listen 80;
                listen [::]:80;
                server_name _;
                return 301 https://$host$request_uri;
        }

        server {
                listen       80;
                listen       [::]:80;
                listen       443 ssl http2;
                listen       [::]:443 ssl http2;
                server_name  localhost;

                ssl_certificate      /etc/ssl/cert.pem;
                ssl_certificate_key  /etc/ssl/privkey.pem;
                ssl_session_cache    shared:SSL:1m;
                ssl_ciphers  HIGH:!aNULL:!MD5;
                ssl_prefer_server_ciphers  on;

                location / {
                        root   /usr/local/www/nginx;
                        index  index.html index.htm;
                }
        }

        server {
                server_name             mysite.com
                listen          80;
                listen [::]:80;
                listen 443 ssl http2;
                listen [::]:443 ssl http2;

                ssl_certificate      /etc/ssl/cert.pem;
                ssl_certificate_key  /etc/ssl/privkey.pem;

               location / {
                   try_files $uri $uri/ /index.php?$args;
               }

               location ~ \.php$ {
                       set $my_https $https;
                       if ($http_x_forwarded_proto = 'https') {
                               set $my_https 'on';
                       }
                       root /var/wordpress;
                       fastcgi_pass 192.168.10.6:9000;
                       fastcgi_index index.php;
                       fastcgi_param SCRIPT_FILENAME /var/wordpress$fastcgi_script_name;
                       include fastcgi_params;
               }
        }
}

相关内容