Good day,
Is it possible for someone to look at my yaml file for review. I keep getting the 502 Bad Gateway (nginx/1.21.1):
# Create a pod containing the php-based application and nginx, each mounting the 'shared-files' volume to their
# respective /var/www/html directories.
# Create a service named nginx-php-service to expose the app on nodePort.
apiVersion: v1
kind: Service
metadata:
name: nginx-phpfpm-service
spec:
type: NodePort
ports:
- port: 8099
targetPort: 8099
nodePort: 30012
---
# First, create a ConfigMap whose contents are used
# as the nginx.conf file in the web server.
# This server uses /var/www/html as its
# root document directory. When the server gets a
# request for *.php, it will forward that request
# to our PHP-FPM container.
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-config
data:
nginx.conf: |
events {
}
http {
log_format main
'remote_addr:$remote_addr\t'
'time_local:$time_local\t'
'method:$request_method\t'
'uri:$request_uri\t'
'host:$host\t'
'status:$status\t'
'bytes_sent:$body_bytes_sent\t'
'referer:$http_referer\t'
'useragent:$http_user_agent\t'
'forwardedfor:$http_x_forwarded_for\t'
'request_time:$request_time';
access_log /var/log/nginx/access.log main;
server {
listen 8099;
server_name localhost;
root /var/www/html;
index index.html index.htm index.php;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
}
}
---
# Create a pod containing the PHP-FPM application (my-php-app)
# and nginx, each mounting the `shared-files` volume to their
# respective /var/www/html directories.
apiVersion: v1
kind: Pod
metadata:
name: nginx-phpfpm
labels:
app: nginx-phpfpm
spec:
volumes:
# Create the shared files volume to be used in both pods.
- name: shared-files
emptyDir: {}
# Add the ConfigMap we declared above as a volume for the pod.
- name: nginx-config-volume
configMap:
name: nginx-config
containers:
# Our nginx container, which uses the configuration declared above,
# along with the files shared with the PHP-FPM app.
- name: nginx-container
image: nginx:latest
volumeMounts:
- name: shared-files
mountPath: /var/www/html
- name: nginx-config-volume
mountPath: /etc/nginx/nginx.conf
subPath: nginx.conf
ports:
- containerPort: 8099
# Our php-fpm application
- name: php-fpm-container
image: php:7.3-fpm
volumeMounts:
- name: shared-files
mountPath: /var/www/html
ports:
- containerPort: 8099