Py学习  »  NGINX

在没有安装卷的nginx的情况下,是否可以将请求传递给php fpm?

You Care • 6 年前 • 884 次点击  

我正在尝试将我的旧单片迁移到K8S,现在我有了nginx和php fpm(带代码)图像,我希望nginx只提供HTTP流量并将其传递给fpm,但是nginx坚持要有文件,我没有 try_files 指令,但它尝试无论如何查找根文件和索引文件。

那么,是否有可能不将源代码装载到nginx,我真的不明白为什么它应该存在,但我找不到任何工作示例

nginx.conf.格式:

server {
    listen 80;

    index index.php;
    # This dir exist only in php-fpm container
    root /var/www/html/public; 

    location ~* \.php$ {

        client_max_body_size 0;

        include fastcgi_params;
        fastcgi_pass php-fpm:9000;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
    }
}

2018/08/17 16:44:40[错误]9 9:*46“/var/www/html/public/index.php”未找到(2:没有此类文件或目录),客户端:192.xxx.xxx.xxx,服务器:,请求:“get/http/1.1”,主机:“localhost”

192.xxx.xxx.xxx-[2018年8月17日:16:44:40+0000]“获取/http/1.1”404 571“-”Mozilla/5.0(x11;Linux x86_64)AppleWebKit/537.36(khtml,类似gecko)Chrome/65.0.3325.146 Safari/537.36“”195.xxx.xxx.xxx”

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/37979
文章 [ 1 ]  |  最新文章 6 年前
Richard Smith
Reply   •   1 楼
Richard Smith    7 年前

index index.php / /index.php

location /

location / {
    rewrite ^ /index.php last;
}
location ~* \.php$ {
    root /var/www/html/public; 
    client_max_body_size 0;

    include fastcgi_params;
    fastcgi_pass php-fpm:9000;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param DOCUMENT_ROOT $document_root;
}