dorbmd1177 2017-11-09 15:11 采纳率: 100%
浏览 145
已采纳

牧场主sidekick php-fpm端口映射

I'm using rancher with this docker-compose:

version: '2'
volumes:
  data: {}
services:
  web:
    image: nginx:latest
    volumes:
    - /some_local_dir/services.conf:/etc/nginx/conf.d/site.conf
    volumes_from:
    - my-service
    ports:
    - 9082:80
    labels:
      io.rancher.sidekicks: my-service
  my-service:
    image: my-service
    volumes:
    - my-service:/my-service
    ports:
    - 9001:9000

my-service - is image build upon alpine3.6, with installed php7-fpm

My services.conf is:

server {
    root /my-service/web;
    server_name my-service.local;

    location / {
        try_files $uri /app.php$is_args$args;
    }
    location ~ ^/app\.php(/|$) {
        fastcgi_pass my-service.web:9001;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param HTTPS off;

        # increase url max size passed to fast CGI interface
        fastcgi_buffer_size 32k;
        fastcgi_buffers 4 32k;
        fastcgi_busy_buffers_size 32k;

        internal;
    }

    error_log  /var/log/nginx/my-service_error.log;
    access_log /var/log/nginx/my-service_access.log;
}

And then I'm getting error :

[error] 10#10: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 10.42.0.1, upstream: "fastcgi://10.42.94.81:9001"

When I remove port mapping, and left fpm port uncahnged (9000:9000) All starts working

Github helped me to find the reason why php-fpm7 wasn't working in the first place, I've updated /etc/php7/php-fpm.d/www.conf in my-service image, instead of default

listen = 127.0.0.1:9000

I wrote

listen = 9000

It makes things works for 9000:9000, but for 9001:9000 - nope ((

Please help to understand how can I forward fpm to 9001, in my case

  • 写回答

1条回答 默认 最新

  • duankang8114 2017-11-11 11:56
    关注

    Seems I misused configs, following entry for the ranchers sidekick means that my-service:9001 will be open for the all external containers, while 9000 remains for the parent container.

    my-service:
        image: my-service
        volumes:
        - my-service:/my-service
        ports:
        - 9001:9000
    

    So I don't need port mapping at all , if I don't want to expose fpm to external containers.

    If there is a need to work on 9001, only way is to redefine defaults of fpm and start it on 9001, or even a more right way - is to use separate pool for the application.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 qt中connect两个signal
  • ¥20 pix2pixHD运行测试命令时出现数据类型错误无法反向传播的问题
  • ¥15 python处理Excel符合条件的行自动填写数据分类
  • ¥15 汇编hook举例并讲解(通俗易懂,学习用)
  • ¥20 用c++语言模拟键盘电子琴设计
  • ¥15 STM32cubemx生成keil工程,有问题与正常的情况不同,求解!
  • ¥15 如何自动点击银行app的安全键盘,实现密码自动输入
  • ¥15 关于四边形重叠的问题
  • ¥15 用verilog语言设计一个简易的八音符电子琴,可通过按键输入来控制音响。演奏时可以选择是手演奏(由键盘输入)或自动演奏已存入的乐曲。能够自动演奏多首乐曲,且每首乐曲可重复演奏
  • ¥15 sap gui脚本每次到导出Excel的时候就停住不动。不会另存为。