First install all required packages:
pkg install git-lite libtool automake autoconf curl
Set up the building blocks:
mkdir /root/build && cd /root/build
fetch https://nginx.org/download/nginx-1.17.10.tar.gz
git clone https://github.com/google/ngx_brotli
cd ngx_brotli && git submodule update --init && cd ..
tar -zxf nginx-1.17.10.tar.gz && rm -f nginx*tar.gz
Configure and make:
cd nginx-*/
./configure --add-module=../ngx_brotli/ --prefix=/usr/local/etc/nginx --with-cc-opt='-I /usr/local/include' --with-ld-opt='-L /usr/local/lib' --conf-path=/usr/local/etc/nginx/nginx.conf --sbin-path=/usr/local/sbin/nginx --pid-path=/var/run/nginx.pid --error-log-path=/var/log/nginx/error.log --user=www --group=www --modules-path=/usr/local/libexec/nginx --with-file-aio --http-client-body-temp-path=/var/tmp/nginx/client_body_temp --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi_temp --http-proxy-temp-path=/var/tmp/nginx/proxy_temp --http-scgi-temp-path=/var/tmp/nginx/scgi_temp --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi_temp --http-log-path=/var/log/nginx/access.log --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gzip_static_module --with-http_gunzip_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_stub_status_module --with-http_sub_module --with-pcre --with-http_v2_module --with-stream=dynamic --with-stream_ssl_module --with-stream_ssl_preread_module --with-threads --with-mail=dynamic --without-mail_imap_module --without-mail_pop3_module --without-mail_smtp_module --with-mail_ssl_module --with-http_ssl_module
make && make install
cd ..
Add to the rc.d (see the actual nginx_freebsd_rcd_script
in this Gist):
mkdir -p /usr/local/etc/rc.d
fetch -o /usr/local/etc/rc.d/nginx https://.../nginx_freebsd_rcd_script
chmod 555 /usr/local/etc/rc.d
chmod 555 /usr/local/etc/rc.d/nginx
sysrc nginx_enable="YES"