Apache vs Nginx, Proxy
Refs
What and why
Apache and Nginx
- Apache: HTTP server, most popular web server, alias
httpd - Nginx: HTTP server, reverse proxy server, mail proxy server, generic TCP/UDP proxy server
Proxy
Proxy: a server application that acts as an intermediary between a client requesting a resource and the server providing that resource.
Forward proxy: Proxy for cilents
Forward proxy purposes:
- get over GFW
- Hide client IP
- Accelerate network access: Usually forward proxy servers holds a large cache which accelerates network access by using cache

- Reverse proxy: Proxy for servers
- Reverse proxy purposes:
- Load balancing
- Hide server IP
- Accelerate network access: Work in a similar way as forward proxy
- Network security: reverse proxy can serve as a fireawll for servers


Apache
Connect Apache and PHP
- In most cases, Apache uses thread-safe version of PHP.
Connect PHP7:
1 | LoadModule php7_module "D:/tools/php-7.4.33-Win32-vc15-x64/php7apache2_4.dll" |
Connect PHP8
- note that module name is not
php8_modulebutphp_module.
Run Apache
by
cmd:- cd
D:/apache24/bin httpd
- cd
as a service:
- cd
D:/apache24/bin httpd -k install: installApache2.4servicenet start apache2.4- Restart:
net stop apache2.4+net start apache2.4orhttpd -k restart
- cd
Nginx
- Nginx: HTTP server, reverse proxy server, mail proxy server, generic TCP/UDP proxy server
Commands
nginx: start servernginx -s reload: reoad configuration filenginx -s stop: fast shutdownnginx -s quit: graceful shutdown
Configuration
Nginx as static server
1 | server { |
1 | http { |
Nginx as HTTP proxy
1 | server { |
Nginx as TCP proxy
1 | stream { |
Apache vs Nginx, Proxy


