Inherit all env variables using Apache

5/1/2019

I see these docs: https://httpd.apache.org/docs/current/mod/mod_env.html

I am looking to inherit/pass all env vars from the host to apache so that I can access them in CGI scripts. Right now the cgi-scripts will log the env vars like so:

#!/usr/bin/env bash
env | sort | while read line; echo "$line <br>"; done

but when the cgi script runs that, it only logs env vars that pertain to apache/httpd, no env vars which are from the outer environment are logged, but why?

So I think am looking to do something like:

PassEnv *

but that's just a guess, anyone know something that might pass all env variables?

To be specific we are using Kubernetes/(AWS EKS), here is our configuration for replicas/pods:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: apache-spike
spec:
  replicas: 3
  template:
    metadata:
      labels:
        app: apache-spike
    spec:
      containers:
      - name: apache-spike
        image: 913617820371.dkr.ecr.us-west-2.amazonaws.com/interos_apache:latest
        ports:
        - name: http-port
          containerPort: 8080
          protocol: TCP
        imagePullPolicy: Always
        env:
          - name: DEMO_GREETING
            value: "Hello from the environment"
          - name: DEMO_FAREWELL
            value: "demo farewell env var"

and when we describe one of the pods, we see:

Containers:
  apache-spike:
    Container ID:   docker://6727d6eafe2a6d229c58875c8cf2c2e9a0cff517dbe67600f965fe19eee000c1
    Image:          9136xxxx0371.dkr.ecr.us-west-2.amazonaws.com/interos_apache:latest
    Image ID:       docker-pullable://9136xxxx0371.dkr.ecr.us-west-2.amazonaws.com/interos_apache@sha256:74f6cab7ef4e1b93123c6e61c7cbdbe5960b736f7e26e075ea5031fb838437be
    Port:           8080/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Tue, 07 May 2019 17:12:07 -0700
    Ready:          True
    Restart Count:  0
    Environment:
      DEMO_GREETING:  Hello from the environment
      DEMO_FAREWELL:  demo farewell env var
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-jhvnp (ro)

so the environment variables are there, at least.

When I run this command on a pod:

kubectl exec apache-spike-579598949b-5bjjs -c apache-spike -- sh -c 'id && ps -e'

I get this:

uid=0(root) gid=0(root) groups=0(root)
  PID TTY          TIME CMD
    1 ?        00:00:04 httpd
    7 ?        00:00:00 httpd
    8 ?        00:00:11 httpd
    9 ?        00:00:09 httpd
   10 ?        00:00:09 httpd
   92 ?        00:00:13 httpd
  204 ?        00:00:00 sh
  211 ?        00:00:00 ps
-- Alexander Mills
amazon-eks
apache
httpd.conf
kubernetes
kubernetes-pod

0 Answers