Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Valid characters in nginx upstream name

Tags:

nginx

In an upstream configuration like this:

upstream name {
    ...
}

I'm wondering what characters can be used in the name. Does it have to be alphanumeric or are there other characters that are also allowed?

like image 887
Frank B Avatar asked Apr 07 '16 19:04

Frank B


People also ask

What is upstream address in nginx?

upstream defines a cluster that you can proxy requests to. It's commonly used for defining either a web server cluster for load balancing, or an app server cluster for routing / load balancing.

How does Nginx resolve upstream?

Upstream Domain Resolve¶ Its buffer has the latest IPs of the backend domain name and it integrates with the configured load balancing algorithm (least_conn, hash, etc) or the built in round robin if none is explicitly defined. At every interval (one second by default), it resolves the domain name.

What is Fail_timeout in nginx?

fail_timeout = time sets. the time during which the specified number of unsuccessful attempts to communicate with the server should happen to consider the server unavailable; and the period of time the server will be considered unavailable.

What is fail timeout?

The fail_timeout and max_fails parameter merely state that if there are a given number of failures during a given time, the server is considered unavailable.

What is NGX_upstream_jdomain?

ngx_upstream_jdomain - an upstream module that resolves an upstream domain name asynchronously. Its buffer has the latest IPs of the backend domain name and it integrates with the configured load balancing algorithm (least_conn, hash, etc) or the built in round robin if none is explicitly defined.

What is the transparent parameter in Nginx?

The transparent parameter (1.11.0) allows outgoing connections to a proxied server originate from a non-local IP address, for example, from a real IP address of a client: In order for this parameter to work, it is usually necessary to run nginx worker processes with the superuser privileges.

How do I write to a temporary file in Nginx?

Writing to temporary files is controlled by the proxy_max_temp_file_size and proxy_temp_file_write_size directives. When buffering is disabled, the response is passed to a client synchronously, immediately as it is received. nginx will not try to read the whole response from the proxied server.

What are the header fields Nginx does not pass?

By default, nginx does not pass the header fields “Date”, “Server”, “X-Pad”, and “X-Accel-...” from the response of a proxied server to a client. The proxy_hide_header directive sets additional fields that will not be passed.


1 Answers

Here's the code that reads a token from configuration file: https://github.com/nginx/nginx/blob/master/src/core/ngx_conf_file.c#L771

Seems that you can use any characters you like, except for spaces, tabs, and variable interpolations. (you can use spaces and tabs if you wrap the upstream name in quotes or escape the characters where necessary).

I've got this abomination to work, so it seems that nginx is fairly liberal in terms of what characters are acceptable:

upstream x_2.2-34%15=54^1@2!&3()4aoeu't {
  server 127.0.0.1:8086;
}
server {
  location / {
    proxy_pass http://x_2.2-34%15=54^1@2!&3()4aoeu't;
  }
}
like image 183
Rogach Avatar answered Oct 01 '22 13:10

Rogach