Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
andrefecto opened this issue Aug 10, 2020 · 3 comments · Fixed by #2449
Closed

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

andrefecto opened this issue Aug 10, 2020 · 3 comments · Fixed by #2449

Comments

@andrefecto
Copy link

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.

@songhanpoo
Copy link

i have same error !

@msandovalN0N
Copy link

Hi all, i have same error! could anyone solve this?

@tkw1536
Copy link
Collaborator

tkw1536 commented Oct 30, 2020

This issue looks like a duplicate of #1466.

@msandovalN0N As mentioned in #1466 (comment) I have implemented a workaround in https://github.com/tkw1536/nginx-proxy-fpm-workaround.

@buchdag buchdag linked a pull request May 16, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants