nginx 和 php-fpm 在靜態內容上回傳 404

nginx 和 php-fpm 在靜態內容上回傳 404

我試圖讓容器 1 上的 nginx 連接到在連接埠 9000 上的容器 2 上運行 wordpress 的 php-fpm。什麼原因造成的?

請注意,第一個「伺服器」區塊旨在捕獲所有非 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;
               }
        }
}

相關內容