Part of configurations in nginx.conf
|
|
Notes
GZip compression
|
|
Session persistence
Set ip_hash for session persistence.
Serving static content
|
|
Change the root for URL starting with “/portal/static/“, letting it the serve the request with local static files.
Server cluster/rack
|
|
upstream is used for proxying requests to other servers.
Conf for websocket:
|
|
The first line tells Nginx to use HTTP/1.1 when communicating to the Node backend, which is required for WebSockets. The next two tell Nginx to respond to the Upgrade request which is initiated over HTTP by the browser when it wants to use a WebSocket.
If the listening port is not 80:
|
|
Note the $server_port part shoud be present. Without it, the redirection will jump to $host:80, rather than the specified port!
Restrict access to the management pages by IP:
|
|
Virtual Host
Each server block represent the one virtual host with its own server_name. Each server blocks looks like:
here each server blocks bind (listen) the port 80, and this server block is only resonds when the server_name value (here blog.server1.com) is matched the HTTP header Host field
location syntax
|
|
Here,
"~" - case sensitive matching
"~*" - case insensitive matching
"=" - forces a literal match between the request URI and the location parameter.
Scripting
Check the great presentation here Introduction to nginx.conf scripting.