duanjiao3754 2019-05-03 14:00
浏览 78

如何调试docker容器请求流

Currently I have 2 docker containers, one is for nginx, the other is for php-fpm. Here's my docker-compose.yml :

version: "3"

services:
    web:
        image: nginx:latest
        ports:
            - "8880:80"
        volumes:
            - .:/usr/share/nginx/html/hr_laravel
            - ./site.conf:/etc/nginx/conf.d/site.conf
            - ./storage/logs/nginx/access.log:/var/log/nginx/access.log
            - ./storage/logs/nginx/error.log:/var/log/nginx/error.log
        links:
            - php

    php:
        image: php:7-fpm
        ports:
            - "9090:9000"
        volumes:
        - .:/var/www/html/hr_laravel

and here's the site.conf :

server {
    listen   80;
    server_name hr.local;

    root /usr/share/nginx/html/hr_laravel/public;
    index index.php index.html;

    error_log  /var/log/nginx/error.log debug;
    access_log /var/log/nginx/access.log;

    location / {
        try_files $uri $uri/ @hr_laravel;
    }

    location @hr_laravel {
        rewrite /hr_laravel/(.*)$ /hr_laravel/index.php?/$1 last;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass php:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}

if I run the docker, and open up the website, it displays File Not Found, and from the log it says

2019/05/03 13:51:25 [error] 7#7: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 172.22.0.1, server: hr.local, request: "GET / HTTP/1.1", upstream: "fastcgi://172.22.0.2:9000", host: "hr.local:8880"

I need to find out how to debug the flow of web request, starting from nginx container and then it's passed into php-fpm container, so I'll know what happen.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器