Multi Docker container with PHP7 fpm and nginx
<p>I am having issues with setting up a multi docker container environment.
The idea is pretty standard:</p>

<ul>
<li>One container have php-fpm running</li>
<li>Another is a nginx proxy</li>
</ul>

<p>My phpfpm Docker file is as simple as:</p>

<pre><code>FROM php:7.0-fpm

# install the PHP extensions we need
RUN apt-get update &amp;&amp; apt-get install -y libpng12-dev libjpeg-dev &amp;&amp; rm -rf /var/lib/apt/lists/* \
    &amp;&amp; docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \
    &amp;&amp; docker-php-ext-install gd mysqli opcache

# set recommended PHP.ini settings
# see https://secure.php.net/manual/en/opcache.installation.php
RUN { \
        echo 'opcache.memory_consumption=128'; \
        echo 'opcache.interned_strings_buffer=8'; \
        echo 'opcache.max_accelerated_files=4000'; \
        echo 'opcache.revalidate_freq=2'; \
        echo 'opcache.fast_shutdown=1'; \
        echo 'opcache.enable_cli=1'; \
    } &gt; /usr/local/etc/php/conf.d/opcache-recommended.ini

VOLUME /var/www/html

CMD ["php-fpm"]
</code></pre>

<p>and Nginx is even more so:</p>

<pre><code>FROM nginx

COPY conf.d/* /etc/nginx/conf.d/
</code></pre>

<p>Where inside the <code>conf.d</code> folder is a single file <code>default.conf</code></p>

<pre><code>server {
    listen 80;
    server_name priz-local.com;
    root /var/www/html;

    index index.php;

    location / {
        proxy_pass  http://website:9000;
        proxy_set_header   Connection "";
        proxy_http_version 1.1;
        proxy_set_header        Host            $host;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}
</code></pre>

<p>And docker-compose.yml</p>

<pre><code>website:
  build: ./website/
  ports:
   - "9000:9000"
  container_name: website
  external_links:
     - mysql:mysql
nginx-proxy:
  build: ./proxy/
  ports:
    - "8000:80"
  container_name: proxy
  links:
       - website:website
</code></pre>

<p>This exact setup works perfectly on AWS Elastic Beanstalk. However, on my local docker I am getting errors such as:</p>

<blockquote>
  <p>2016/11/17 09:55:36 [error] 6#6: *1 connect() failed (111: Connection
  refused) while connecting to upstream, client: 172.17.0.1, server:
  priz-local.com, request: "GET / HTTP/1.1", upstream:
  "<a href="http://127.0.0.1:9000/" rel="nofollow noreferrer">http://127.0.0.1:9000/</a>", host: "priz-local.com:8888"
  172.17.0.1 - - [17/Nov/2016:09:55:36 +0000] "GET / HTTP/1.1" 502 575 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1)
  AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71
  Safari/537.36" "-"</p>
</blockquote>

<p><strong>UPDATE</strong>
If I log into the proxy container and try curl to the other one I am getting this:</p>

<pre><code>root@4fb46a4713a8:/# curl http://website
curl: (7) Failed to connect to website port 80: Connection refused
root@4fb46a4713a8:/# curl http://website:9000
curl: (56) Recv failure: Connection reset by peer
</code></pre>

<p>Another thing I tried is:</p>

<pre><code>server {
    listen 80;
    server_name priz-local.com;
    root /var/www/html;

    #index index.php;
    #charset UTF-8;

    #gzip on;
    #gzip_http_version 1.1;
    #gzip_vary on;
    #gzip_comp_level 6;
    #gzip_proxied any;
    #gzip_types text/plain text/xml text/css application/x-javascript;

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    location /nginx_status {
        stub_status on;
        access_log off;
    }

    location / {
        try_files $uri $uri/ /index.php?q=$uri&amp;$args;
    }

    location ~ \.php$ {

        set $nocache "";
        if ($http_cookie ~ (comment_author_.*|wordpress_logged_in.*|wp-postpass_.*)) {
           set $nocache "Y";
        }

        fastcgi_pass  website:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_intercept_errors on;
        include fastcgi_params;

        #fastcgi_cache_use_stale error timeout invalid_header http_500;
        #fastcgi_cache_key $host$request_uri;
        #fastcgi_cache example;
        #fastcgi_cache_valid 200 1m;
        #fastcgi_cache_bypass $nocache;
        #fastcgi_no_cache $nocache;
    }

    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
        allow all;
        expires max;
        log_not_found off;

        fastcgi_pass  wordpress:9000;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_intercept_errors on;
        include fastcgi_params;
    }
}
</code></pre>

<p>The site started to work, but all the resources (js|css|png|jpg|jpeg|gif|ico) are now returning <code>403</code>.</p>

<p>What am I missing?</p>