Kubernetes Nginx ingress setup for Strapi with x-forwarded headers

If you’re using Strapi and you’re trying to figure out how to setup Nginx Ingress for Kubernetes or you are trying to solve one of the following issues:
https://github.com/strapi/strapi/issues/3462
https://github.com/strapi/strapi/issues/2424

Here’s the ingress configuration, and your nginx ingress helm chart value you should be editing:

#1 Provide use-forwarded-headers in your helm chart’s controller config params

# values.yaml
controller:
  config:
    use-forwarded-headers: "true"

#2 My ingress config

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/use-regex: "true"
    nginx.ingress.kubernetes.io/proxy-body-size: 200m
    nginx.ingress.kubernetes.io/enable-cors: "true"
    nginx.ingress.kubernetes.io/cors-allow-origin: "*"
    nginx.ingress.kubernetes.io/cors-allow-headers: "*"
    nginx.ingress.kubernetes.io/cors-allow-credentials: "true"
    nginx.ingress.kubernetes.io/cors-allow-methods: "*"
    nginx.ingress.kubernetes.io/proxy-connect-timeout: "30s"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "20s"
    nginx.ingress.kubernetes.io/client-body-buffer-size: "50m"
    kubernetes.io/ingress.class: nginx
  name: strapi-ingress
spec:
  rules:
  - host: mydomain.com
    http:
      paths:
      - path: /
        backend:
          serviceName: angular-ui
          servicePort: 80
      # Depends on the plugins you use
      - path: /(admin|plugins|email|settings-manager|documentation|content-type-builder|upload|users-permissions|users|content-manager|auth)/?.*$
        backend:
          serviceName: strapi
          servicePort: 1337

#3 Custom nginx ingress installation

You might want to create a custom configmap to us within your nginx ingress installation like the following:

apiVersion: v1
data:
  use-forwarded-headers: "true"
kind: ConfigMap
metadata:
  name: nginx-configuration

#4 Digital Ocean k8s

or if you are running your k8s in Digital Ocean you need to add few more config params, but I’d suggest you read this full blog post:

https://www.digitalocean.com/community/questions/how-to-set-up-nginx-ingress-for-load-balancers-with-proxy-protocol-support?answer=50313

#5 Nginx map directive

If you are simply using Nginx as a load balancer, you might want to setup the map directive outside your server block like the solution provided in this comment: https://github.com/strapi/strapi/issues/2424#issuecomment-445964719

CircleCI notifications in RocketChat

There is no official CircleCI integration for RocketChat, therefore this has to be done a little manually.

Below is an example of how I use it.

.circleci/config.yml

version: 2
jobs:
  build-development:
    docker:
      - image: debian:stretch
    steps:
        - checkout
        - run: 
            command: apt-get update && apt-get install -y curl
        - run:
            name: Greeting from hello
            command: echo "Hello, world from hello."
        - run:
            name: Notifiation Failed
            command: bash .circleci/notify "failed"
            when: on_fail
        - run:
            name: Notification Sucess
            command: bash ./circleci/notify "success"
            when: on_success
        
workflows:
  version: 2
  build-deploy:
    jobs:
      - build-development
          filters:
            branches:
              only:
                - develop

Note that on_fail will only execute if one of the above will fail, same with on_success, it only executes if all of the above are successful.

.circleci/notify


#!/bin/bash
set -euo pipefail

payload=$(
cat <<EOM
{
    "status": "$1",
    "job": "$CIRCLE_JOB",
    "build_num": "$CIRCLE_BUILD_NUM",
    "project_reponame": "$CIRCLE_PROJECT_REPONAME",
    "branch": "$CIRCLE_BRANCH",
    "build_url": "$CIRCLE_BUILD_URL",
    "compare_url": "$CIRCLE_COMPARE_URL",
    "sha1": "$CIRCLE_SHA1"
}
EOM
)

curl -X POST -H 'Content-Type: application/json' --data "$payload" https://YOUR-ROCKETCHAT/hooks/INCOMING-WEBHOOK-INTEGRATION-URL

RocketChat Incoming WebHook Integration

class Script {
  
  process_incoming_request({ request }) {
     
    var alertColor = "warning";
    
    let status = request.content.status;
    let job = request.content.job;
    let build_num = request.content.build_num;
    let project_reponame = request.content.project_reponame;
    let branch = request.content.branch;
    let build_url = request.content.build_url;
    let sha1 = request.content.sha1;
      
    if (status == "success") {
    	alertColor = "good";
    } else if (status == "failed") {
    	alertColor = "danger";
    }

    let textMessage = (status == "failed" ? "@all\n" : "");
        
    let title = status == "failed" ? " build failed!" : " was built successfully!"
    
    textMessage = textMessage + "*Build no*: " + build_num + "\n*Project*: " + project_reponame + "\n*Branch*: " + branch + "\n*Commit*: " + sha1

    return {
    	content: {
	    username: "CircleCI",
            attachments: [{
		text: textMessage,
                color: alertColor,
                title: job + title,
                title_link: build_url
            }]
        }
    };

    return {
    	error: {
        	success: false
        }
    };
  }
}

Windows vs. Mac OS X vs. Linux: The Operating System Battle

Windows, Mac OS X, or Linux? That has been the age-old dilemma that is now gaining more and more attention as each operating system is progressing at a record pace. This summary will give you a comprehensive and thorough examination of each operating system, their advantages, disadvantages, and a final summary of which one is better. Please note that all conclusions are self-drawn opinions that are supported by facts. However, it does not guarantee that these thoughts are truths. Continue reading “Windows vs. Mac OS X vs. Linux: The Operating System Battle”

Open source wars: WordPress vs Drupal vs Joomla

Every IT person, developer, and programmer has an opinion when it comes to the various open source content management systems out there. It often comes down to functionality and ease of use, but even then the lines are often blurred and there is rarely a clear-cut victor. WordPress vs Drupal vs Joomla – which is really the king of open source CMS? Continue reading “Open source wars: WordPress vs Drupal vs Joomla”

How to change VLC player skin

We all like VLC its the best Video player ever, simply it rocks.. but sometimes we like to see it on another skin..

Peace of cake !

Here’s how we do it :
Go to this page http://www.videolan.org/vlc/skins.php and download any of the skins you like….
I’m gonna get the WinShit Media Player : http://www1.videolan.org/vlc/download-skins2-go.php?url=WMP_B_2.vlt

Open VLC and go to Tools > Preferences

Now Under the Interface Tab enable Skins as shown in photo Browse the file that you downloaded from the site above and click save… Continue reading “How to change VLC player skin”

The Free Software Definition

Free software” is a matter of liberty, not price. To understand the concept, you should think of “free” as in “free speech,” not as in “free beer.”

Free software is a matter of the users’ freedom to run, copy, distribute, study, change and improve the software. More precisely, it means that the program’s users have the four essential freedoms:

  • The freedom to run the program, for any purpose (freedom 0).
  • The freedom to study how the program works, and change it to make it do what you wish (freedom 1). Access to the source code is a precondition for this.
  • The freedom to redistribute copies so you can help your neighbor       (freedom 2). Continue reading “The Free Software Definition”

Configuring Ipko GPRS in Android phones

Thanks to my friend (colleague) Lulzim Gashi who figured out this, we were able to find the way how to configure the ipko GPRS in Android Phones.. because even Ipko guys weren’t capable to solve it by saying we don’t support this kind of phone
SAMSUNG Galaxy GT-I5800 “lol bulsh**”

Anyway lets proceed

1.Send a sms to 123 with the word “plus gprs” (you’ll get a message saying: Your gprs is activated) GOOD !
2.Now you have to configure your phone by following these steps :

  • Open Applications
  • Go to Settings
  • Wireless and network
  • Mobile networks
  • Access Point Names

Now you’ll se that the Access Point Names is blank so what you have to do is click the left Button on your phone and press Continue reading “Configuring Ipko GPRS in Android phones”

Best Python Blogs

Best python blogs:

I just wanted to share, these are the best python blogs I have found till now,
And they also have good material… tutorials and stuff.. :

http://planet.python.org/
http://blog.doughellmann.com/search/label/PyMOTW
http://www.voidspace.org.uk/python/weblog/index.shtml
http://blog.ianbicking.org/category/python/
http://python-history.blogspot.com/

Create your own Python Blog : http://www.pythonblogs.com/

Python Tutorials : Click Here !