I have a brand new symfony 5 app in a docker container, on which I need to receive some webhook, thus using ngrok for tunneling. Thing is, ngrok keep sending me 502 errors, whereas the localhost access is doing fine. I'm kinda running out of ideas.
Curl using 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"}
Docker logs while using localhost:
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 started with:
$ 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
Curl through 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
Docker logs through ngrok (same as before):
payment_1 | [Web Server/PHP ] Jul 23 09:17:07 |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:17:07 |DEBUG| PHP
payment_1 | [Web Server/PHP ] Jul 23 09:17:07 |INFO | SERVER GET (200) ]8;;https://127.0.0.1:8004/default\/default]8;;\ ip="172.20.0.1"
Ngrok console (seems ok):
HTTP Requests
-------------
GET /default 200 OK
The docker container is lauched with symfony dev server via docker compose (docker-compose.yml extract):
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"
And here is the 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
I really don't understand what is going wrong. I have other container with similar configurations that seems to work fine. I've tried rebuilding the container, and various ngrok commands using *:4080 or http://127.0.0.1:4080, or some -host-header options. Also tried differents ports to no results. Result is of course the same in browser.