apiVersion: v1
kind: ConfigMap
metadata:
  name: cota-wordpress-nginx
  namespace: oshk
data:
  default.conf: |
    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;
        #access_log  /var/log/nginx/host.access.log  main;

        root   /var/www/html;
        index index.php index.html index.htm;

        location / {
            try_files $uri $uri/ /index.php?q=$uri&$args;
            rewrite ^/wp-content/uploads/(.*)$ https://hkcota.blob.core.windows.net/wp-upload/$1 permanent;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        #error_page   500 502 503 504  /50x.html;
        #location = /50x.html {
        #    root   /usr/share/nginx/html;
        #}

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass   localhost:9000;
            fastcgi_index  index.php;
            include        fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
            fastcgi_param HTTPS on;
        }

        location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
          access_log        off;
          log_not_found     off;
          expires           360d;
        }

        # deny access to hideen files
        #
        location ~ /\. {
          access_log off;
          log_not_found off;
          deny  all;
        }
    }
  nginx.conf: |
    user  root;
    worker_processes  1;
    error_log  /dev/stderr warn;
    pid        /var/run/nginx.pid;

    events {
      worker_connections  1024;
    }

    http {
      include       /etc/nginx/mime.types;
      default_type  application/octet-stream;
      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  /dev/stdout  main;

      sendfile        on;
      #tcp_nopush     on;

      keepalive_timeout  65;
      #gzip  on;
      include /etc/nginx/conf.d/*.conf;
    }
