caddy logline for combined log format

Posted on Updated on

You can use this log line to get the “Combined Log Format” in caddy.

log / stdout “{remote} – – [{when}] \”{method} {path} {proto}\” {status} {size} \”{>Referer}\” \”{>User-agent}\””

or the predefined format “{combined}”

The placeholders are described at and the log directive at

In case that you are behind a reverves proxy or loadbalancer you will need also to add this directive to the caddy file, to get the real ip.

realip {

Of course you will change the from partūüėČ
The realip directive is described at


Posted on

Dear Reader.

don’t think to use sunrise prepaid.
The support is really really bad.

My prepaid setup have only ~256 K.
I was in 2 different Shops they have no glue what happen. They have assumed something but can’t say what’s wrong with the setup.

After a call to the support hotline, which also not helps I decide now another Phone provider.
I will try swisscomm I hope they are less crappy then the

external Services with openshift v3 and haproxy

Posted on


Openshift V3 offers a simple solution to call external services.

Integrating External Services

This solution lacks some possibilities like use DNS names or use more then one destination.

The here described solution offers you the flexibility of haproxy with logs for this service.

Here the picture for the solution.



  • openshift v3
  • own git repository
  • haproxy 1.6
  • socklog / syslog
  • destination address(s)
  • patienceūüėČ

openshift v3 and git repo

I expect that you have access to a openshift (oc …/ webconsole) and a read / write access to a git


You can use the official image on docker hub haproxy I suggest to use the alpine one. I have used this for a small http-https redirector which you can find here. A example with log settings is here

socklog / syslog

Due to the fact that there is no official docker hub entry for socklog you can use my repo

destination address(s)

Well to which service do you want to connect is your decisionūüėČ


Now you should take a look into the excellence documentation of haproxy.

Start of Implemantation

Create a new Project

oc new-project externel-service001

or when you admin and want to be able to run this pods on dedicated nodes you can use

oadm new-project externel-service001 --node-selector='your-dmz=external-router'

Create socklog/syslog

oc new-app -e TZ=Europe/Vienna --dry-run -o yaml > 01_build_socklog.yaml
oc create -f 01_build_socklog.yaml

Output of the creation

imagestream "alpine" created
imagestream "alpine-socklog" created
buildconfig "alpine-socklog" created
deploymentconfig "alpine-socklog" created
service "alpine-socklog" created

Q: Why do I use a file for  the cretion not directly?

A: For reproduction and debugging. It’s easier do make a oc delete -f 01_build_socklog.yamlūüėČ

Now we have a alpine-socklog service wiith  exposed port 8514/udp

oc get svc
alpine-socklog <none> 8514/UDP 3m

and a listening daemon which writes the requests out to stdout

oc logs -f alpine-socklog-1-mldc6
listening on, starting.


Don’t use the user/uid and group/gid on openshift!

Dont’t use daemon option in openshift!

Create git

Due to the fact that you will need to change the haproxy conf you need a git repository.

I use mineūüėČ

git clone

Now edit the containerfiles/etc/haproxy/haproxy.cfg and add the log option.

Create haproxy

Commit it to your repo and create the app

oc new-app -e TZ=Europe/Vienna --dry-run -o yaml > metadata/01_build_haproxy.yaml
oc create -f metadata/01_build_haproxy.yaml


imagestream "http-https-redirector" created
buildconfig "http-https-redirector" created
deploymentconfig "http-https-redirector" created
service "http-https-redirector" created
Error from server: imageStream "alpine" already exists

After some times you will see the pods up and running

oc get po
NAME                            READY     STATUS      RESTARTS   AGE
alpine-socklog-1-build          0/1       Completed   0          10h
alpine-socklog-1-mldc6          1/1       Running     0          10h
http-https-redirector-1-build   0/1       Completed   0          4m
http-https-redirector-2-build   0/1       Completed   0          1m
http-https-redirector-2-k56kr   1/1       Running     0          35s

in the log of alpine-socklog-1-mldc6 pod you will see the log-entries of haproxy.

[al@localhost openshift-external-services]$ oc logs -f alpine-socklog-1-mldc6
listening on, starting. local0.notice: Apr 27 18:29:18 haproxy[1]: Proxy entry-point started. local0.notice: Apr 27 18:29:18 haproxy[1]: Proxy google started.

Add route

To be able to use this service now add a route.

oc expose svc http-https-redirector

When everything works as expect you should see something like this. local0.notice: Apr 27 19:56:25 haproxy[1]: Proxy entry-point started. local0.notice: Apr 27 19:56:25 haproxy[1]: Proxy be_google started. Apr 27 19:56:55 haproxy[1]: [27/Apr/2016:19:56:55.189] entry-point be_google/srv_google/ 0/0/111/18/129 404 1686 - - ---- 1/1/0/1/0 0/0 "GET / HTTP/1.1" Apr 27 19:57:21 haproxy[1]: [27/Apr/2016:19:57:21.555] entry-point be_google/srv_google/ 0/0/42/18/60 404 1686 - - ---- 1/1/0/1/0 0/0 "GET / HTTP/1.1"

You need now to look into the doc of haproxy and alpine to fix the time and the ip issue unless you don’t need to know which client have requested your serviceūüėČ

Another option is to hire one of Cloudwerkstatt GmbH to fix that for you.

HTTP to HTTPS with Openshift V3

Posted on

Due to the fact that the current OpenShift V3 (3.1) only offer with Edge Termination a redirect  from HTTP to HTTPS you will need a similar concept as described below.

In a non OpenShift V3 you normaly handle the HTTP to HTTPS as following.


The application server or reverse proxy handle the HTTP¬†request and sends a redirect to HTTPS. It’s a easy setup for the most servers out there.

Due to the fact that OpenShift V3 is not able to handle one hostname in two backends the flow above will not work in the current ( 3.1 ) version.

To be able to handle the redirect you will need something like this.


This means you need to setup a dedicated Service with a haproxy < 1.6.

Please take a look into the description of Server IP address resolution using DNS for full details.

The server line in haproxy must follow this pattern


as described in OpenShift DNS .

There is a RH Buzilla enty for this and also a github issue.

Make OpenShift console available on port 443 (https)

Posted on Updated on


The main reason why this blog post exist is that OpenShift V3 and Kubernetes is very close binded to port 8443. This could be changed in the future.

We at Cloudwerkstatt GmbH use a dedicated haproxy pod to provide the OpenShift v3 Web console on port 443 (https).

This concept could be used also for different services in the PaaS.

There are some ansible variables for openshift_master_api_port and openshift_master_console_port which suggest that you are able to change the port.

This ports are ‘internal’ ports and not designed to be the public ports. So changing this ports could crash your OpenShift setup!

In case that you want to you this variables you will also need to change a lot of OpenShift v3 and Kubernetes.

The describe solution is a more global and flexible solution then the external service solution.
The external service solution is much easier to setup it is described here

You will need the following to run this setup.

  • Time!
  • Understanding of OpenShift v3, Kubernetes and docker
  • SSL-Certificate for master.<your-domain> or *.<your-domain>
  • write access to a git repository
  • ssh key for deployment [optional]

Here a rudimentary picture which shows the idea and the flow.



Btw: Does I said you will need Time and Knowledge!ūüėČ

git clone

Due to the fact that you need to change the haproxy conf you must have a git repository from which OpenShift is able to build the haproxy

You can try to use this repo as base .

git clone

Adopt ENV

You need to change the OPENSHIFT_MASTER_SERVER variable in the Dockerfile

Adopt master.cfg

You need to change the container-files/etc/haproxy/master.cfg

Add this into the global section.

ca-base /etc/ssl
crt-base /etc/ssl

Add ssl options to bind line

you need to add this to the bind line

ssl no-sslv3 crt /etc/ssl/certificates-all.pem

Test run

You can try the build with a simple docker build command

docker build --rm -t myhaproxy .

Now run

docker run -it --rm --net host -e OPENSHIFT_MASTER_SERVER=<your-master-ip> myhaproxy

When everything works you need to push the data to your git repository

git stuff

git add .
git commit -m 'init'
git push -u origin master

Create the project

oc new-project infra-services

Add ssl keys to service account

oc secrets new manage-certificate  certificates-all.pem=.../zerts_manage-certificate_all.pem
oc secrets add serviceaccount/default secret/manage-certificate

oc new-app

now create the app.

oc new-app <your-repo-url> --name=openshift-master

oc edit dc

You need to add the secret into the container.

Please take a look into the concept of the secrets here.

oc edit dc -n infra-services openshift-master
        volumeMounts: <-- Add from here 
        - mountPath: /etc/ssl
          name: secret-volume
          readOnly: true <-- until this line
      terminationGracePeriodSeconds: 30
      volumes: <-- Add from here
      - name: secret-volume
          secretName: manage-certificate

After saving the changes a rebuild will start.

oc expose

Make the setup public available over the OpenShift default router

oc expose service openshift-master --hostname=manage.<your-domain>

Test #1

After all this steps and build process you should now see a running podūüėČ

A call to

curl -sS https://manage.<your-domain>|egrep hostPort

should now show the OpenShift internal masterPublicURL

egrep -i masterPublicURL /etc/origin/master/master-config.yaml

Ansible hosts file

To configure OpenShift with the new URL please add the following lines to the ansible hosts file

openshift_master_public_api_url=https://manage.{{ osm_default_subdomain }}
openshift_master_public_console_url={{ openshift_master_public_api_url }}/console
openshift_master_metrics_public_url={{ openshift_master_public_api_url }}/hawkular/metrics

and rerun the ansible playbook as described here

ANSIBLE_LOG_PATH=/tmp/ansible_log_$(date +%Y_%m_%d-%H_%M) ansible-playbook /usr/share/ansible/openshift-ansible/playbooks/byo/config.yml

Test #2

A call to

curl -sS https://manage.<your-domain>|egrep hostPort

should now show the OpenShift new public masterPublicURL

egrep -i masterPublicURL /etc/origin/master/master-config.yaml

Which should be the master.<your-domain>

ansible on centos 7.1

Posted on Updated on

You need the following packages after a centos minial installation

 yum install git gcc python-devel

Then follow the commands in the doc

If you get the following error.

# ansible all -m ping
Traceback (most recent call last):
 File "/root/ansible/bin/ansible", line 39, in <module>
 from ansible.utils.display import Display
 File "/root/ansible/lib/ansible/utils/", line 28, in <module>
 from ansible import constants as C
 File "/root/ansible/lib/ansible/", line 26, in <module>
 from six.moves import configparser
ImportError: No module named six.moves

try to install

pip install six

This is six

This is the used python version.

# python -V
Python 2.7.5


Posted on Updated on

I have searched for a ping for the ajp protocol ( ) and found some

From my point of view they have some weakness.

  • not¬†accurate¬†enough for the current it environments
  • don’t¬†measure the operations
  • don’t write a graph-able line out

Due to these facts I have used jffry’s (¬† ) script as base for my extended version.

With the output line

%Y-%m-%d %T host %s ip %s port %s connect %f syswrite %f sysread %f timeouted %d timeout %d good_answer %d

you can easily create a picture with your preferred¬†tool ( gnuplot, splunk, excel, R, …)