Php Ngrok隧道至停靠的symfony 5在502 bad gateway结束

Php Ngrok隧道至停靠的symfony 5在502 bad gateway结束,php,docker,symfony,ngrok,Php,Docker,Symfony,Ngrok,我在docker容器中有一个全新的symfony 5应用程序,我需要在上面接收一些webhook,从而使用ngrok进行隧道挖掘。问题是,ngrok不断向我发送502个错误,而localhost访问做得很好。 我有点没主意了 使用localhost进行卷曲: $ curl -v http://localhost:4080/default * Trying ::1... * TCP_NODELAY set * Connected to localhost (::1) port 4080 (#0

我在docker容器中有一个全新的symfony 5应用程序,我需要在上面接收一些webhook,从而使用ngrok进行隧道挖掘。问题是,ngrok不断向我发送502个错误,而localhost访问做得很好。 我有点没主意了

使用localhost进行卷曲:

$ curl -v http://localhost:4080/default
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 4080 (#0)
> GET /default HTTP/1.1
> Host: localhost:4080
> User-Agent: curl/7.52.1
> Accept: */*
> 
< HTTP/1.1 200 OK
< Cache-Control: no-cache, private
< Content-Type: application/json
< Date: Thu, 23 Jul 2020 09:10:43 GMT
< PHP message: [info] Matched route "default".
< X-Powered-By: PHP/7.4.3
< X-Robots-Tag: noindex
< Content-Length: 93
< 
* Curl_http_done: called premature == 0
* Connection #0 to host localhost left intact
{"message":"Welcome to your new controller!","path":"src\/Controller\/DefaultController.php"}
payment_1                 | [Web Server/PHP ] Jul 23 09:10:43 |INFO | PHP    PHP message: Matched route "default". path="/usr/local/sbin/php-fpm" php="7.4.3"
payment_1                 | [Web Server/PHP ] Jul 23 09:10:43 |DEBUG| PHP     
payment_1                 | [Web Server/PHP ] Jul 23 09:10:43 |INFO | SERVER GET  (200) ]8;;https://127.0.0.1:8004/default\/default]8;;\ ip="172.20.0.1"
Ngrok从以下方面开始:

$ ngrok http 4080
ngrok by @inconshreveable                                                                                                                                                                          (Ctrl+C to quit)
                                                                                                                                                                                                                   
Session Status                online                                                                                                                                                                               
Account                       lulhum (Plan: Free)                                                                                                                                                                  
Version                       2.3.35                                                                                                                                                                               
Region                        United States (us)                                                                                                                                                                   
Web Interface                 http://127.0.0.1:4040                                                                                                                                                                
Forwarding                    http://8c882c861512.ngrok.io -> http://localhost:4080                                                                                                                                
Forwarding                    https://8c882c861512.ngrok.io -> http://localhost:4080                                                                                                                               
                                                                                                                                                                                                                   
Connections                   ttl     opn     rt1     rt5     p50     p90                                                                                                                                          
                              0       0       0.00    0.00    0.00    0.00
卷曲通过ngrok:

$ curl -v http://8c882c861512.ngrok.io/default
*   Trying 3.137.63.131...
* TCP_NODELAY set
* Connected to 8c882c861512.ngrok.io (3.137.63.131) port 80 (#0)
> GET /default HTTP/1.1
> Host: 8c882c861512.ngrok.io
> User-Agent: curl/7.52.1
> Accept: */*
> 
< HTTP/1.1 502 Bad Gateway
< Content-length: 107
< Cache-Control: no-cache
< Connection: close
< Content-Type: text/html
< 
<html><body><h1>502 Bad Gateway</h1>
The server returned an invalid or incomplete response.
</body></html>
* Curl_http_done: called premature == 0
* Closing connection 0
Ngrok控制台(似乎正常):

docker容器通过docker compose(docker-compose.yml extract)与symfony开发服务器一起启动:

下面是Dockerfile:

FROM php:7.4-fpm-alpine

RUN apk add --no-cache \
  git \
  curl \
  openssl \
  ssmtp \
  libzip-dev \
  bash

RUN docker-php-ext-install -j$(nproc) \
  pcntl \
  zip

RUN apk add --no-cache icu-dev
RUN docker-php-ext-install intl

RUN wget https://get.symfony.com/cli/installer -O - | bash \
    && mv /root/.symfony/bin/symfony /usr/local/bin/symfony

RUN curl https://raw.githubusercontent.com/composer/getcomposer.org/d3e09029468023aa4e9dcd165e9b6f43df0a9999/web/installer | php -- --quiet \
    && mv composer.phar /usr/local/bin/composer

WORKDIR /app

ENV TZ="Europe/Paris"
ENV IS_DOCKER=1
我真的不明白出了什么问题。我有其他类似配置的容器,似乎可以正常工作。 我尝试过使用*:4080或,或一些-host头选项重建容器和各种ngrok命令。也尝试了不同的端口,但没有结果。
当然,在浏览器中的结果是相同的。

我已经缩小了问题的范围。问题出在symfony服务器的某个地方,添加了奇怪的
PHP消息:[info]匹配的路由“default”。
标题。 此消息由记录器发出,应发送至stderr。不知道它是怎么到那里的

由于它不遵循传统的头语法,我假设ngrok无法读取头并返回到502

我已经提出了一个解决方案,同时使用了基本的php服务器

HTTP Requests                                                                                                                                                                                                      
-------------                                                                                                                                                                                                      
                                                                                                                                                                                                                   
GET /default                   200 OK 
version: '3'
services:

  payment:
    build: ./payment
    command: sh -c "symfony server:stop && symfony server:start --port=4080"
    environment:
      APP_DEBUG: 1
      VAR_DUMPER_SERVER: payment_dump:8000
    volumes:
      - "./payment:/app"
      - "payment_composer:/root/composer"
    expose:
      - 4080
    ports:
      - "4080:4080"
FROM php:7.4-fpm-alpine

RUN apk add --no-cache \
  git \
  curl \
  openssl \
  ssmtp \
  libzip-dev \
  bash

RUN docker-php-ext-install -j$(nproc) \
  pcntl \
  zip

RUN apk add --no-cache icu-dev
RUN docker-php-ext-install intl

RUN wget https://get.symfony.com/cli/installer -O - | bash \
    && mv /root/.symfony/bin/symfony /usr/local/bin/symfony

RUN curl https://raw.githubusercontent.com/composer/getcomposer.org/d3e09029468023aa4e9dcd165e9b6f43df0a9999/web/installer | php -- --quiet \
    && mv composer.phar /usr/local/bin/composer

WORKDIR /app

ENV TZ="Europe/Paris"
ENV IS_DOCKER=1