nginx-proxy: Cannot connect to container with fastcgi
I am having trouble getting fastcgi support to work which was introduced in #863. I am using jwilder/nginx-proxy:alpine
and php:fpm-alpine
images for testing and I get this error in the logs of nginx-proxy
and a 404
in the browser:
FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream
I am setting up the containers with Ansible:
- name: Pull php-fpm container
docker_container:
name: php-fpm
image: php:fpm-alpine
pull: true
restart_policy: always
ports:
- "9000:9000"
env:
VIRTUAL_HOST: phpfpm.local
VIRTUAL_ROOT: /var/www/html
VIRTUAL_PORT: 9000
VIRTUAL_PROTO: fastcgi
And the generated configuration in nginx looks like this:
# phpfpm.local
upstream phpfpm.local {
## Can be connect with "bridge" network
# php-fpm
server 172.17.0.6:9000;
}
server {
server_name phpfpm.local;
listen 80 ;
access_log /var/log/nginx/access.log vhost;
include /etc/nginx/vhost.d/default;
location / {
root /var/www/html;
include fastcgi.conf;
fastcgi_pass phpfpm.local;
}
}
I placed a index.php
with phpinfo()
in /var/www/html
and set permissions to www-data
.
Any ideas how to debug this further?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 18 (3 by maintainers)
same issue here, i’m using this conf
when trying access to browser, blank response, any ideas?
I’ve added this line in my custom dockerfile (FROM jwilder/nginx-proxy:alpine):
RUN echo "fastcgi_index index.php;" >> /etc/nginx/fastcgi.conf
Works but it would be good to have something like “-e VIRTUAL_INDEX=index.php”
I am facing the same issue as xgenvn:
Here you can see state of container:
I solved the problem by replace the file fastcgi_params to own:
add build section to proxy docker-composer.yml:
build.dockerfile:
This is indeed my negligence caused. In my project, I added a rewrite, did not find this problem. I will consider fixing it as soon as possible.
@saesh @HalisCz Hello, this bug has been resolved. See #1116
@saesh actually I’m using repo and it referenced directly from this image for the template. I checked the nginx configuration but there’re no fastcgi.conf in nginx folder. I’ll fire an issue on that repo instead 😉.
Just for completion: I added a virtual host specific location configuration file in
/etc/nginx/vhost.d/phpfpm.local_location
with just one line:fastcgi_index index.php;
and now all works as intended. See per-virtual_host-location-configuration in the README.