Skip to content

PHP-FPM with suggested ReadMe setup doesn't work #1489

@andrefecto

Description

@andrefecto

The suggested setup for using a fastcgi back-end doesn't seem to work, it just returns blank pages.
Here is my docker-compose for the fastcgi backend:

version: '3'
services:
   php:
    container_name: <container name>
    image:  php:7.4-fpm-alpine3.12
    restart: 'unless-stopped'
    environment:
      VIRTUAL_PROTO: fastcgi
      VIRTUAL_ROOT: /var/www/html/
      url: <https url>
      VIRTUAL_HOST: <virtual_host fqdn>
      LETSENCRYPT_HOST: <virtual_host fqdn>
      LETSENCRYPT_EMAIL: <my email>
    volumes:
      - ./data/www/html:/var/www/html
      - ./data/php/:/usr/local/etc/php/
networks:
  default:
    external:
      name: nginx-proxy

This is what gets produced in my nginx default.conf by the nginx-proxy-gen container:

# <site fqdn>
upstream <site fqdn> {
                                ## Can be connected with "nginx-proxy" network
                        # <site name>
                        server 172.21.0.3:9000;
}
server {
        server_name <site fqdn>;
        listen 80 ;
        access_log /var/log/nginx/<site name>_access.log vhost;
        return 301 https://$host$request_uri;
}
server {
        server_name <site fqdn>;
        listen 443 ssl http2 ;
        # MY EDITS HERE
        access_log /var/log/nginx/<site name>_access.log vhost;
        client_max_body_size 100M;
        ssl_session_timeout 5m;
        ssl_session_cache shared:SSL:50m;
        ssl_session_tickets off;
        ssl_certificate /etc/nginx/certs/<site fqdn>.crt;
        ssl_certificate_key /etc/nginx/certs/<site fqdn>.key;
        ssl_dhparam /etc/nginx/certs/<site fqdn>.dhparam.pem;
        ssl_stapling on;
        ssl_stapling_verify on;
        ssl_trusted_certificate /etc/nginx/certs/<site fqdn>.chain.pem;
        add_header Strict-Transport-Security "max-age=31536000" always;
        include /etc/nginx/vhost.d/default;
        location / {
                root   /var/www/html/;
                include fastcgi_params;
                fastcgi_pass <site fqdn>;
        }
}

Here is what I see in my access log:

<site fqdn> <my ip> - - [10/Aug/2020:12:19:19 -0600] "GET / HTTP/2.0" 200 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:79.0) Gecko/20100101 Firefox/79.0"

With everything above you just get blank pages back when you try and visit your or any page at /*.

Now, outside of the suggested setup I have tried adding the following custom location block to the vhost and adding to the default / location block for the vhost:

Added to the nginx_proxy_vhost/_location file:

    try_files $uri $uri/ /index.php?$args;

Added to just the nginx_proxy_vhost/ file:


    location ~ [^/]\.php(/|$) {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        include fastcgi_params;
        fastcgi_pass <site fqdn>
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

Those additions will produce the base PHP file but any CSS/JS/PNG/JPEG files will return nothing.

My goal is to have this setup for a PHP site: (Nginx Reverse proxy container) -> (php-fpm container) instead of (Nginx Reverse proxy container) -> (Apache container) because running the php-fpm container to server the PHP content while also producing the css/js/images is a lot more lightweight than nginx+Apache behind it and it's a lot faster.

Any help getting this working is appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions