hhxsv5 / laravel-s

LaravelS is an out-of-the-box adapter between Laravel/Lumen and Swoole.
MIT License
3.83k stars 472 forks source link

按照你docker/compose项目配置环境后访问一直502 #114

Closed u5de6 closed 5 years ago

u5de6 commented 5 years ago
  1. Tell us your software version How to know it?

    # PHP
    php -v
    # Swoole
    php --ri swoole
    # Laravel
    grep 'laravel/framework' composer.json
    # Lumen
    grep 'laravel/lumen-framework' composer.json
    Software Version
    PHP 7.3.0
    Swoole 4.2.9
    LaravelS 3.3.9
    Laravel Framework [local] 5.5.44
  2. Detail description about this issue(error/log)

    按照你的docker-compose来部署的开发环境,laravels.com普通的静态资源访问ok,但其他路由访问出现502 php7容器内访问是正常的

    $ winpty docker-compose exec php7 sh
    # curl http://127.0.0.1:5200
    敬请期待...
    #
  3. Give us a reproducible code block and steps

    nginx的配置没做其他的调整
    nginx的错误提示:
    [error] 7#7: *31 connect() failed (111: Connection refused) while connecting to upstream, client: 172.18.0.1, server: laras.io, request: "GET / HTTP/1.1", upstream: "http://172.18.0.6:5200/", host: "laras.io"
hhxsv5 commented 5 years ago

listen_ip配置0.0.0.0了吗?

oknixus commented 4 years ago

请教一个问题,如果是宿主机访问容器中的项目,都必须监听0.0.0.0吗?有没有不指定0.0.0.0的? 实际测试中 docker run -p 127.0.0.1:5200:5200 镜像名 sh时,也是502错误,只有将listen_ip改为0.0.0.0才能正常访问,在laravel-s中这个是固定设置吗? 谢谢!

补充: 我的nginx是在宿主机中,PHP环境在容器中

hhxsv5 commented 4 years ago

@oknixus 了解下0.0.0.0127.0.0.1区别,Docker 网络模式host bridge

oknixus commented 4 years ago

谢谢回复! 区别还是知道的,记得之前MongoDB的一直都是0.0.0.0全网监听,后来就发生了几次安全事件,才改为127.0.0.1

oknixus commented 4 years ago

可以在.env文件中设置LARAVELS_LISTEN_IP=php,这里的phpdocker-compose.ymlphp服务的名称