ยง2023-04-16


  1. Rebuild
$ pwd
/home/alexlai/build/ngx_markdown_filter_module  <-- this is a git clone
$ git tag
0.1.0
0.1.1
$ git branch
* master
  1. get nginx source, make and make install
$ wget http://nginx.org/download/nginx-1.24.0.tar.gz
$ cd ../
$ tar xvf src/nginx-1.24.0.tar.gz 
$ cd nginx-1.24.0
$ ./configure --add-module=../ngx_markdown_filter_module \
--pid-path=/run/nginx.pid \
--lock-path=/run/lock/nginx.lock \
--user=http --group=http \
--http-log-path=/var/log/nginx/access.log \
--error-log-path=stderr \
--http-client-body-temp-path=/var/lib/nginx/client-body \
--http-proxy-temp-path=/var/lib/nginx/proxy \
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
--http-scgi-temp-path=/var/lib/nginx/scgi \
--http-uwsgi-temp-path=/var/lib/nginx/uwsgi \
--with-compat \
--with-debug \
--with-file-aio \
--with-http_addition_module \
--with-http_auth_request_module \
--with-http_dav_module  \
--with-http_degradation_module \
--with-http_flv_module \
--with-http_geoip_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_mp4_module \
--with-http_realip_module \
--with-http_secure_link_module \
--with-http_slice_module \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_sub_module \
--with-http_v2_module \
--with-mail \
--with-mail_ssl_module \
--with-pcre-jit \
--with-stream \
--with-stream_geoip_module \
--with-stream_realip_module \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \
--with-threads 
...
Confadding module in ../ngx_markdown_filter_module
 + ngx_markdown_filter_module was configured
checking for PCRE2 library ... found
checking for OpenSSL library ... found
checking for zlib library ... found
checking for GeoIP library ... found
checking for GeoIP IPv6 support ... found
creating objs/Makefile

Configuration summary
  + using threads
  + using system PCRE2 library
  + using system OpenSSL library
  + using system zlib library

  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/run/nginx.pid"
  nginx logs errors to stderr
  nginx http access log file: "/var/log/nginx/access.log"
  nginx http client request body temporary files: "/var/lib/nginx/client-body"
  nginx http proxy temporary files: "/var/lib/nginx/proxy"
  nginx http fastcgi temporary files: "/var/lib/nginx/fastcgi"
  nginx http uwsgi temporary files: "/var/lib/nginx/uwsgi"
  nginx http scgi temporary files: "/var/lib/nginx/scgi"

$ time make -j6
...
objs/addon/ngx_markdown_filter_module/ngx_markdown_filter_module.o \
objs/ngx_modules.o \
-lpthread -lcrypt -l:libcmark.so -lpcre2-8 -lssl -lcrypto -lpthread -lz -lGeoIP \
-Wl,-E
make[1]: Leaving directory '/home/alexlai/build/nginx-1.24.0'

real	0m31.399s
user	1m43.944s
sys	0m18.016s

$ sudo make install
[sudo] password for alexlai: 
make -f objs/Makefile install
make[1]: Entering directory '/home/alexlai/build/nginx-1.24.0'
test -d '/usr/local/nginx' || mkdir -p '/usr/local/nginx'
test -d '/usr/local/nginx/sbin' \
	|| mkdir -p '/usr/local/nginx/sbin'
test ! -f '/usr/local/nginx/sbin/nginx' \
	|| mv '/usr/local/nginx/sbin/nginx' \
		'/usr/local/nginx/sbin/nginx.old'
cp objs/nginx '/usr/local/nginx/sbin/nginx'
test -d '/usr/local/nginx/conf' \
	|| mkdir -p '/usr/local/nginx/conf'
cp conf/koi-win '/usr/local/nginx/conf'
cp conf/koi-utf '/usr/local/nginx/conf'
cp conf/win-utf '/usr/local/nginx/conf'
test -f '/usr/local/nginx/conf/mime.types' \
	|| cp conf/mime.types '/usr/local/nginx/conf'
cp conf/mime.types '/usr/local/nginx/conf/mime.types.default'
test -f '/usr/local/nginx/conf/fastcgi_params' \
	|| cp conf/fastcgi_params '/usr/local/nginx/conf'
cp conf/fastcgi_params \
	'/usr/local/nginx/conf/fastcgi_params.default'
test -f '/usr/local/nginx/conf/fastcgi.conf' \
	|| cp conf/fastcgi.conf '/usr/local/nginx/conf'
cp conf/fastcgi.conf '/usr/local/nginx/conf/fastcgi.conf.default'
test -f '/usr/local/nginx/conf/uwsgi_params' \
	|| cp conf/uwsgi_params '/usr/local/nginx/conf'
cp conf/uwsgi_params \
	'/usr/local/nginx/conf/uwsgi_params.default'
test -f '/usr/local/nginx/conf/scgi_params' \
	|| cp conf/scgi_params '/usr/local/nginx/conf'
cp conf/scgi_params \
	'/usr/local/nginx/conf/scgi_params.default'
test -f '/usr/local/nginx/conf/nginx.conf' \
	|| cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf'
cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf.default'
test -d '/run' \
	|| mkdir -p '/run'
test -d '/var/log/nginx' \
	|| mkdir -p '/var/log/nginx'
test -d '/usr/local/nginx/html' \
	|| cp -R html '/usr/local/nginx'
make[1]: Leaving directory '/home/alexlai/build/nginx-1.24.0'
  1. nginx.service
[Unit]
Description=A high performance web server and a reverse proxy server
After=network.target network-online.target nss-lookup.target

[Service]
Type=forking
PIDFile=/run/nginx.pid
PrivateDevices=yes
SyslogLevel=err

ExecStart=/usr/local/nginx/sbin/nginx -g 'pid /run/nginx.pid; error_log stderr;'
ExecReload=/usr/local/nginx/sbin/nginx -s reload
KillMode=mixed

[Install]
WantedBy=multi-user.target
  1. /usr/local/nginx/conf/nginx.conf
#user  nobody;
worker_processes  1;

error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {
    worker_connections  2048; # original 1024
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    charset utf-8;

    # try to correct ngx_markdown_filter_module
    client_max_body_size 100M;
    # Set the buffer size for reading client request body
    client_body_buffer_size 10M;
    # Set the buffer size for reading from the upstream server
    proxy_buffer_size 64k;
    # Set the number and size of buffers used for reading from the upstream server
    proxy_buffers 8 64k;
    # Set the size of the buffer used for reading from the upstream server when the connection is busy
    proxy_busy_buffers_size 128k;
    # Set the timeout for reading from the upstream server
    proxy_read_timeout 300s;

    #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  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       8888;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
            autoindex on;
            autoindex_exact_size off;
            autoindex_localtime on;
        }

        # Render Markdown files as HTML pages using ngx_http_markdown_filter_module
        location ~ \.md$ {
            add_header Content-Type 'text/html';
            markdown_filter on;
            markdown_template /usr/local/nginx/html/template.html;
            # markdown_template html/template.html;
            # sub_filter_types *;
            # sub_filter '</body>' '<div style="padding: 20px;">$markdown$</div></body>';
        }

        #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   html;
        }


    }

}