Skip to content

Instantly share code, notes, and snippets.

@iameli
Created August 30, 2016 17:16
Show Gist options
  • Select an option

  • Save iameli/650c125d8e6ac43d030fafd05c46bd5a to your computer and use it in GitHub Desktop.

Select an option

Save iameli/650c125d8e6ac43d030fafd05c46bd5a to your computer and use it in GitHub Desktop.
Just a cool way to run a customized nginx from one file in Kubernetes.
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: cachet
namespace: csats-com
spec:
template:
metadata:
labels:
app: cachet
spec:
volumes:
- name: nginx-config
configMap:
name: nginx-config
containers:
- image: nginx:stable-alpine
name: nginx-config
volumeMounts:
- name: nginx-config
mountPath: /etc/nginx/conf.d
---
kind: ConfigMap
apiVersion: v1
metadata:
name: nginx-config
namespace: csats-com
data:
default.conf: |-
server {
listen 80 default; ## Listen for ipv4; this line is default and implied
# Make site accessible from http://localhost/
server_name localhost;
root /var/www/html/public;
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# Cache images
location ~* .(jpg|jpeg|png|gif|ico|css|js|ttf)$ {
expires 365d;
}
# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_pass localhost:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
fastcgi_keep_conn on;
}
location ~ /\.ht {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment