Chapter 6: Web Servers — Nginx and Apache
Interview Questions
- Q1. What is the difference between Nginx and Apache?
- Nginx is event-driven and asynchronous, very efficient for static content and reverse proxying. Apache uses process/thread-based MPMs, has many modules and supports per-directory
.htaccessfiles. - Q2. What is a reverse proxy?
- A server that receives client requests and forwards them to backend servers/apps (e.g. Node on 127.0.0.1:3000), then returns the response. It provides TLS termination, caching, load balancing and security.
- Q3. How do you test Nginx configuration before applying it?
sudo nginx -t, thensudo service nginx reloadif the test passes.- Q4. What do HTTP 403, 404 and 502 mean?
- 403 Forbidden (permission/SELinux/no index), 404 Not Found (wrong path/root), 502 Bad Gateway (the upstream app behind the proxy is down or unreachable).
- Q5. What is SELinux and how do you fix a web-content label issue?
- Security-Enhanced Linux, a mandatory access control system on RHEL/CentOS. Fix labels with
sudo restorecon -Rv /var/www/site(orsemanage fcontextfor custom paths). - Q6. What is
.htaccessand why doesn't Nginx support it? - A per-directory Apache config file read on every request. Nginx avoids it for performance; all configuration lives in central files.