NGINX kann noch mehr, als im Normalfall mit eingepflegt ist. Auf Basis der Plesk-Umgebung haben wir uns NGINX zur Brust genommen und Erweiterungen mit einkompiliert.

Diese, vor allem um noch mehr Performance und Services aus den leichten Webserver heraus zu kitzeln.

Basis ist Ubuntu 16 LTS mit installiertem Plesk 17.8. Dazu ist NGINX als Proxy vorinstalliert. Leider kann es sein, dass nach erfolgreichem Kompilieren und Installieren ein Update oder Upgrade von Plesk den NGINX als Binary wieder überschreibt. Hier ist also zukünftig acht zu geben, und die Changelogs sollten vor einem Update genau durchgesehen werden.

Vorbereitung

Als erstes werden einige Pakete installiert, welche wir für das Kompilieren und Installieren benötigen.

sudo apt install build-essential zlib1g-dev libpcre3 libpcre3-dev unzip libperl-dev libxml-libxml-perl libxml2-dev libxml2-utils python-libxml2 libxslt1.1 libxslt1-dev python-libxslt1 libxml-filter-xslt-perl libxml-libxslt-perl libgd-dev libgd-perl libgd-text-perl python-gd libgoogle-perftools4 libgoogle-perftools-dev libgeoip-dev libuuid1 uuid-dev

Anforderungen

Wir laden die zusätzlichen Sourcen in ein Verzeichnis.

mkdir /home/nginx-compile
cd /home/nginx-compile

Stand Downloads: 20.02.2018.

wget https://nginx.org/download/nginx-1.13.8.tar.gz
wget https://github.com/apache/incubator-pagespeed-ngx/archive/v1.13.35.2-stable.tar.gz
wget https://github.com/google/brotli/archive/v1.0.2.tar.gz
wget https://github.com/FRiCKLE/ngx_cache_purge/archive/2.3.tar.gz
wget https://github.com/FRiCKLE/ngx_slowfs_cache/archive/1.10.tar.gz
wget https://github.com/FRiCKLE/ngx_coolkit/archive/0.2.tar.gz
wget https://github.com/openresty/headers-more-nginx-module/archive/v0.33.tar.gz

Google Brotli

git clone https://github.com/google/ngx_brotli.git
cd ngx_brotli
git submodule update --init --recursive

OpenSSL

git clone https://github.com/openssl/openssl.git
cd openssl
git checkout tls1.3-draft-18
./config shared enable-tls1_3 --prefix=/usr/share/openssl --openssldir=/usr/share/openssl -Wl,-rpath,'$(LIBRPATH)'

Passenger

cd /home/nginx-compile/incubator-pagespeed-ngx-1.13.35.2-stable
wget https://dl.google.com/dl/page-speed/psol/1.13.35.2-x64.tar.gz
tar -xzvf 1.13.35.2-x64.tar.gz # expands to psol/

Konfigurieren und Kompilieren

Nun kompilieren wir den NGINX neu. Sämtliche Sourcen sollten an ihren Orten liegen. Sofern ohne Plesk kompiliert wird, kann auf –add-module=/usr/share/passenger/ngx_http_passenger_module bei Bedarf verzichtet werden.

Weiter kann es sein, dass natürlich gewisse Module nicht gewünscht sind. Diese können in der Konfigurationsanweisung unten entfernt werden. Hier ein Beispiel einer Konfiguration zur Vorbereitung des Kompilierens (auf Basis Plesk-Vorlage).

Konfiguration

./configure --prefix=/etc/nginx \
    --sbin-path=/usr/sbin/nginx \
    --conf-path=/etc/nginx/nginx.conf \
    --error-log-path=/var/log/nginx/error.log \
    --http-log-path=/var/log/nginx/access.log \
    --lock-path=/var/lock/nginx.lock \
    --pid-path=/var/run/nginx.pid \
    --http-client-body-temp-path=/var/lib/nginx/body \
    --http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
    --http-proxy-temp-path=/var/lib/nginx/proxy \
    --http-scgi-temp-path=/var/lib/nginx/scgi \
    --http-uwsgi-temp-path=/var/lib/nginx/uwsgi \
    --user=nginx \
    --group=nginx \
    --with-debug \
    --with-file-aio \
    --with-google_perftools_module \
    --with-mail \
    --with-mail_ssl_module \
    --with-threads \
    --with-select_module \
    --with-stream \
    --with-stream_ssl_module \
    --with-http_addition_module \
    --with-http_auth_request_module \
    --with-http_dav_module \
    --with-http_flv_module \
    --with-http_geoip_module \
    --with-http_gunzip_module \
    --with-http_gzip_static_module \
    --with-http_image_filter_module \
    --with-http_mp4_module \
    --with-http_perl_module \
    --with-http_random_index_module \
    --with-http_realip_module \
    --with-http_secure_link_module \
    --with-http_stub_status_module \
    --with-http_sub_module \
    --with-http_ssl_module \
    --with-http_v2_module \
    --with-http_xslt_module \
    --with-poll_module \
    --with-openssl=/home/nginx-compile/openssl \
    --with-openssl-opt=enable-tls1_3 \
    --add-module=/home/nginx-compile/ngx_brotli \
    --add-module=/home/nginx-compile/incubator-pagespeed-ngx-1.13.35.2-stable \
    --add-module=/usr/share/passenger/ngx_http_passenger_module \
    --add-module=/home/nginx-compile/ngx_cache_purge-2.3 \
    --add-module=/home/nginx-compile/ngx_coolkit-0.2 \
    --add-module=/home/nginx-compile/ngx_slowfs_cache-1.10 \
    --add-module=/home/nginx-compile/headers-more-nginx-module-0.33

Kompilieren und Installieren

Nach erfolgreichem Konfigurieren und Kompilieren kann der neue NGINX installiert werden.

make
make install

Verwenden der neuen Features

Google Brotli und Google Pagespeed können über die NGINX-Konfigurationsanweisungen in Plesk bequem nun eingeschaltet werden. Als Beispiel die folgende Konfiguration.

brotli on;
brotli_static on;
brotli_types text/html text/plain text/css application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon image/vnd.microsoft.icon image/bmp image/svg+xml;
brotli_comp_level 8;
 
pagespeed on;
pagespeed LowercaseHtmlNames on;
pagespeed XHeaderValue "Powered by ngx_pagespeed and UF";
pagespeed StaticAssetPrefix /static/;
pagespeed FileCachePath /var/ngx_pagespeed_cache;
pagespeed PreserveUrlRelativity on;
pagespeed EnableFilters combine_css,rewrite_css,move_css_above_scripts,combine_javascript,rewrite_javascript;
pagespeed EnableFilters lazyload_images,inline_preview_images,resize_mobile_images,inline_google_font_css,rewrite_style_attributes;
pagespeed EnableFilters prioritize_critical_css,make_google_analytics_async,outline_css,outline_javascript,move_css_to_head;
pagespeed EnableFilters include_js_source_maps,canonicalize_javascript_libraries,local_storage_cache,convert_to_webp_lossless,insert_image_dimensions;
pagespeed EnableFilters elide_attributes,extend_cache_pdfs,sprite_images,trim_urls,pedantic;
pagespeed EnableFilters remove_quotes,dedup_inlined_images,insert_dns_prefetch,remove_comments,collapse_whitespace;
pagespeed EnableFilters in_place_optimize_for_browser;

Die neuen SSL-Konfiguration kann im separaten /etc/nginx/conf.d/ssl.conf hinterlegt werden. Auch hier ein Beispiel daür.

ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers 'TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS';
ssl_prefer_server_ciphers on;
ssl_ecdh_curve secp384r1;

Kommentar schreiben

Ihre E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert