Nginx
Appearance
![]() | |
Developer(s) | Nginx dev team |
---|---|
Stable release |
1.15.8
/ December 25, 2018 |
Operating system | Cross-platform |
Type | Web server |
License | 2-clause BSD-like license |
Website | nginx.org |
nginx (pronounced “engine-x”) is an open source Web server and a reverse proxy server for HTTP, SMTP, POP3 and IMAP protocols, with a strong focus on high concurrency, performance and low memory usage. It is licensed under a BSD-like license and it runs on Unix, Linux, BSD, Mac OS X, Solaris, AIX and Microsoft Windows.[1]
Nginx Configuration Options[edit | edit source]
- expires - Controls whether the response should be marked with an expiry time, and if so, what time that is.
- gzip - This module allows for on-the-fly gzip compression. See also Gzip pre-compression module.
- gzip pre-compression - Before serving a file from disk to a gzip-enabled client, this module will look for a precompressed file in the same location that ends in ".gz".
Nginx Proxy Configuration Options[edit | edit source]
A Very Simple Nginx Proxy Setup[edit | edit source]
In the below example, you need to set nginx-ip-here & ip-address-of-your-server.
server { #Turns access log off access_log off; #Set this to the IP on the nginx server you want to represent this proxy listen nginx-ip-here:80; #Matches the requested hostname server_name your-hostname.com www.your-hostname.com; location / { # Tells the destination server the IP of the visitor (some take X-Real-IP, # some take X-Forwarded-For as their header of choice proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; # Tells the destination server which hostname you want proxy_set_header Host $host; # Performs a Proxy Pass to that server proxy_pass http://ip-address-of-your-server; } }
Multiple Server Configuration (with two domains)[edit | edit source]
upstream www.domain1.com { server 192.168.10.11:80; server 192.168.10.12:80; } server { listen 80; server_name www.domain1.com; location / { proxy_pass http://www.domain1.com; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } upstream www.domain2.com { server 192.168.10.21:80; server 192.168.10.22:80; } server { listen 80; server_name www.domain2.com; location / { proxy_pass http://www.domain2.com; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } access_log /usr/local/nginx/logs/domain2.log www; }
Controlling Nginx[edit | edit source]
Changing Configuration[edit | edit source]
After updating the configuration of Nginx, you can send a HUP signal to the master process to have Nginx reload the configuration. [2]
nginx -s reload
Rotating Nginx's Log files[edit | edit source]
Upgrading Nginx's binaries[edit | edit source]
References[edit | edit source]
- ↑ nginx.org - Retrieved 2011-10-15.
- ↑ Nginx.org - Controlling nginx - Reconfiguration - Retrieved 2012-02-18.