Nginx Optimization, DNS Configuration, and Anti‑Hotlinking Setup on CentOS
This article walks through installing Nginx on CentOS, configuring DNS across three servers, applying common Nginx hardening techniques such as version hiding, log rotation, connection keep‑alive tuning, image caching, and implementing anti‑hotlinking to protect site resources.
Introduction
A reader failed a technical interview because they could not answer questions about Nginx optimization, anti‑hotlinking, and related security practices, so this guide revisits those topics with practical examples.
Topology
Three CentOS machines are used: Centos01 runs Nginx (domain www.h.com ), Centos02 runs Apache (domain www.hy.com ), and Centos03 provides DNS services.
Step 1 – Install Nginx on Centos01
# mount /dev/cdrom /mnt/ # useradd -M -s /sbin/nologin nginx # rz # receive nginx‑1.16.1 source package # yum -y install pcre-devel zlib-devel # tar -zxvf nginx‑1.16.1.tar.gz && cd nginx‑1.16.1 # vim src/core/nginx.h # modify version strings # vim src/http/ngx_http_header_filter_module.c # change Server header # ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module # make && make install # ln -s /usr/local/nginx/sbin/* /usr/local/sbin/ # nginx -t # test configuration # mkdir /www && echo "www.h.com" > /www/index.htmlSelected Java Interview Questions
A professional Java tech channel sharing common knowledge to help developers fill gaps. Follow us!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.