Sign inSign up

fwestermark/header-app

By fwestermark

Updated 8 months ago

Simple web-server based on openresty that serves web pages primarily for internal http debugging.

Image
Networking
Security
Web servers
0

2.0K

fwestermark/header-app repository overview

Introduction

This docker image is based on openresty and echoes back http headers from the client for debug. The image is built using openresty/openresty-alpine-apk docker image. Nothing except modifying the nginx.conf file has been changed.

Installation

Clone this repository and edit to your liking or pull from docker-hub. Edit the nginx.conf file to your liking. Visit https://openresty.org for available variables and configuration.

Using docker

docker run --name header-app -p 80:80 fwestermark/header-app:latest

Using docker-compose
  header-app:
    image: fwestermark/header-app:latest
    container_name: header-app
    hostname: header-app
    restart: unless-stopped
    ports:
      - 80:80
      - 443:443
#   volumes:
#     - ./headers-app/nginx.conf:/usr/local/openresty/nginx/conf/nginx.conf:ro
#     "touch" or edit the nginx.conf file prior starting the image or docker will assume the file nginx.conf is a directory.

A configuration more from daily life:

  header-app:
    image: fwestermark/header-app:latest
    container_name: header-app
    hostname: header-app
    restart: unless-stopped
    ports:
      - <ip>:80:80
      - <ip>:443:443
    volumes:
      - ./header-app/nginx.conf:/usr/local/openresty/nginx/conf/nginx.conf:ro
      - ./header-app/config:/usr/local/openresty/nginx/conf/config:ro
      - ./header-app/html:/usr/local/openresty/nginx/html:ro
      - ./header-app/http.access.log:/var/log/http.access.log
      - ./header-app/https.access.log:/var/log/https.access.log
      - ./header-app/cert.pem:/etc/ssl/private/cert.pem:ro
      - ./header-app/private.key:/etc/ssl/private/private.key:ro
      - ./header-app/ca_chain.pem:/etc/ssl/private/ca_chain.pem:ro

Example NGINX config
events {
    worker_connections          1024;
}

http {
    log_format                  custom '$remote_addr - $ssl_client_s_dn - $remote_user [$time_local] "$request" '
                                '$status $body_bytes_sent "$http_referer" "$http_user_agent" "$upstream_response_time"';
    error_log stderr            debug;
    default_type                application/octet-stream;


    server {
      server_name               header-app.domain.tld;
      ssi                       on;
      listen                    80;
      access_log                /var/log/http.access.log custom;
      root                      /usr/local/openresty/nginx/html;
      index                     index.html index.htm;
      add_header                X-Real-Server $hostname;
      location / {
        try_files               $uri $uri/index.html $uri/ =404;
      }
      location /errorcodes/501/ {
        return                  501 '501 error';
      }
      location /errorcodes/503/ {
        return                  503 '503 error';
      }
    }


    server {
      server_name               header-app.domain.tld;
      ssi                       on;
      listen                    443 ssl;
      access_log                /var/log/https.access.log custom;
      root                      /usr/local/openresty/nginx/html;
      index                     index.html index.htm;
      add_header                X-Real-Server $hostname;
      ssl_protocols             TLSv1.1 TLSv1.2 TLSv1.3;
      ssl_prefer_server_ciphers on;
      ssl_ciphers               ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
      ssl_certificate           /etc/ssl/private/cert.pem;
      ssl_certificate_key       /etc/ssl/private/private.key;
      ssl_client_certificate    /etc/ssl/private/rawlish_ca_chain.pem;
      ssl_verify_client         optional;
      location / {
        try_files               $uri $uri/index.html $uri/ =404;
      }
      location /errorcodes/501/ {
        return                  501 '501 error';
      }
      location /errorcodes/503/ {
        return                  503 '503 error';
      }
   }
}

Example NGINX html directory
.
├── css
│   └── style.css
├── favicon.ico
├── index.html
└── info
    └── index.html
I particulary like this page that echoes back the server point of view covering client certificate, tls requests etc.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<link href="/css/style.css" type="text/css" rel="stylesheet" />
</head>

<body>
<h2><!--# echo var="server_name" --></h2>
<pre>

date is <!--# echo var="date_local" -->
tcp connect from <!--# echo var="remote_addr" -->

====== start: client tls request

TLS protocol: <!--# echo var="ssl_protocol" -->
Client selected ciphers: <!--# echo var="ssl_cipher" -->
Client provided SNI name: <!--# echo var="ssl_server_name" -->

Client certificate serial number: <!--# echo var="ssl_client_serial" -->
Client certificate end date: <!--# echo var="ssl_client_v_end" --> (<!--# echo var="ssl_client_v_remain" --> days remaining)
Certificate issuer: <!--# echo var="ssl_client_i_dn" -->
Certificate subject: <!--# echo var="ssl_client_s_dn" -->

====== end: client tls request



====== start: client http request headers

<!--# echo var="echo_client_request_headers" -->
====== end: client http request headers



====== start: client request body

<!--# echo var="request_body" -->

====== end: client request body



====== start: server response

requested content



<< EOF
</pre>

</body>
</html>
License

Distributed under the MIT License. See LICENSE for more information.

Acknowledgements

Based on idea from https://github.com/brndnmtthws/nginx-echo-headers

Tag summary

Content type

Image

Digest

sha256:f3db92f6e

Size

12 MB

Last updated

8 months ago

docker pull fwestermark/header-app