Directive can have multiple meanings. Each variant is separated with horizontal line
[edit] server
| Syntax: |
server { ... } |
| Default: |
|
| Context: |
http |
| Reference: |
server |
Directive assigns configuration for the virtual server.
There is no separation of IP and name-based (the Host header of the request) servers.
Instead, the directive listen is used to describe all addresses and ports on which incoming connections can occur, and in directive server_name indicate all names of the server.
Module: HttpCoreModule
[edit] server
| Syntax: |
server address [ parameters ] |
| Default: |
|
| Context: |
upstream |
| Reference: |
server |
Directive assigns the name and the parameters of server. For the name it is possible to use a domain name, an address, port or unix socket. If domain name resolves to several addresses, then all are used.
- weight = NUMBER - set weight of the server, if not set weight is equal to one.
- max_fails = NUMBER - number of unsuccessful attempts at communicating with the server within the time period (assigned by parameter fail_timeout) after which it is considered inoperative. If not set, the number of attempts is one. A value of 0 turns off this check. What is considered a failure is defined by proxy_next_upstream or fastcgi_next_upstream (except http_404 errors which do not count towards max_fails).
- fail_timeout = TIME - the time during which must occur *max_fails* number of unsuccessful attempts at communication with the server that would cause the server to be considered inoperative, and also the time for which the server will be considered inoperative (before another attempt is made). If not set the time is 10 seconds. fail_timeout has nothing to do with upstream response time, use proxy_connect_timeout and proxy_read_timeout for controlling this.
- down - marks server as permanently offline, to be used with the directive ip_hash.
- backup - (0.6.7 or later) only uses this server if the non-backup servers are all down or busy (cannot be used with the directive ip_hash)
Example configuration:
upstream backend {
server backend1.example.com weight=5;
server 127.0.0.1:8080 max_fails=3 fail_timeout=30s;
server unix:/tmp/backend3;
}
Attention: If you use only one upstream server nginx set a internal variable to 1, this means that the max_fails & fail_timeout parameter are not handled.
Effect: If nginx can not connect to upstream the request it's gone.
Solution: Use the same server several times
Module: HttpUpstreamModule
[edit] server
syntax: server {...}
default: no
context: mail
Directive assigns configuration for the virtual server.
There is no clear separation of the virtual servers ip-based and name-based (the value of the line "Host" header in the request).
Instead of this by directives listen are described all addresses and ports, on which it is necessary to assume connections for this server, and in directive server_name are indicated all names of servers. Example configurations are described in tuning of virtual servers.
Module: MailCoreModule