Wordpress (PHP-FPM) + Nginx not serving content

5/23/2018

got a problem with a wordpress + nginx deployment not serving php content
It can server html documents

nginx log:

[23/May/2018:04:33:56 +0000] "GET / HTTP/1.1" 200 5 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36"

wordpress (phpfpm) log:

127.0.0.1 -  23/May/2018:04:33:56 +0000 "- " 200

So wordpress fpm is getting the request but nothing is returned/computed?
nginx.conf:

user  www-data;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    index         index.php;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    client_body_buffer_size 32k;
    client_header_buffer_size 1k;
    large_client_header_buffers 4 8k;
    # php max upload limit cannot be larger than this
    client_max_body_size 33m;

    proxy_buffers 16 32k;
    proxy_buffer_size 64k;

    fastcgi_buffers 16 128k;
    fastcgi_buffer_size 256k;

    upstream php {
        #server unix:/tmp/php-cgi.socket;
        server localhost:9000;
    }

    fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=WORDPRESS:100m inactive=60m;
    fastcgi_cache_key "$scheme$request_method$host$request_uri";
    fastcgi_cache_use_stale error timeout invalid_header http_500;
    fastcgi_ignore_headers Cache-Control Expires Set-Cookie;

    real_ip_header X-Forwarded-For;
    set_real_ip_from 0.0.0.0/0;

    limit_req_zone $binary_remote_addr zone=one:10m rate=16r/s;
    limit_req_zone $binary_remote_addr zone=two:10m rate=30r/m;
    limit_conn_zone $binary_remote_addr zone=addr:10m;
    limit_conn addr 10;
    limit_conn_status 444;

    include /etc/nginx-conf/conf.d/*.conf;
}

Wordpress.conf (nginx-conf/conf.d):

server {
      ## Your website name goes here.
      server_name _;
      ## Your only path reference.
      ## This should be in your http block and if it is, it's not needed here.
      # index index.php;

      root /var/www/html;
      include /etc/nginx-conf/global/*.conf;

      location / {
              # This is cool because no php is touched for static content.
              # include the "?$args" part so non-default permalinks doesn't break when using query string
              try_files $uri /index.php?$args;
      }

      location ~ \.php$ {
              #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
              limit_req zone=one burst=12 nodelay;
              include fastcgi_params;
              fastcgi_pass php;
      }
}

let me know if you need additional configuration documents

Edit:
Deployment:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: wordpress
  labels:
    app: wordpress
  namespace: default
spec:
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: wordpress
  template:
    metadata:
      labels:
        app: wordpress
    spec:   
      containers:
      - name: wordpress
        image: wordpress:4.9-php7.2-fpm
        env:
        - name: WORDPRESS_DB_HOST
          value: mysql-service
        - name: WORDPRESS_DB_NAME
          value: wordpress
        - name: WORDPRESS_DB_USER
          value: wordpress
        - name: WORDPRESS_DB_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mysql-wordpress-pass
              key: password
        volumeMounts:
        - name: wordpress-persistent-storage
          mountPath: /var/www/html
        - name: php
          mountPath: /usr/local/etc/php/conf.d
        - name: cache
          mountPath: /var/run/nginx-cache

      - name: nginx
        image: nginx:1.14
        ports:
        - containerPort: 80
        env:
        volumeMounts:
        - name: wordpress-persistent-storage
          mountPath: /var/www/html
        - name: nginx
          mountPath: /etc/nginx/
        - name: nginx-conf-d
          mountPath: /etc/nginx-conf/conf.d
        - name: nginx-global
          mountPath: /etc/nginx-conf/global
        - name: nginx-html
          mountPath: /etc/nginx-conf/html
        - name: cache
          mountPath: /var/run/nginx-cache
      volumes:
      - name: wordpress-persistent-storage
        persistentVolumeClaim:
          claimName: wordpress-pvc
      - name: php
        configMap:
          name: php
      - name: cache
        emptyDir:
          medium: Memory
      - name: nginx
        configMap:
          name: nginx
      - name: nginx-conf-d
        configMap:
          name: nginx-conf-d
      - name: nginx-global
        configMap:
          name: nginx-global
      - name: nginx-html
        configMap:
          name: nginx-html
-- Nathan Ogden
docker
kubernetes
nginx
php
wordpress

0 Answers