annotate auto/lib/geoip/conf @ 9017:106328a70f4e

Added warning about redefinition of listen socket protocol options. The "listen" directive in the http module can be used multiple times in different server blocks. Originally, it was supposed to be specified once with various socket options, and without any parameters in virtual server blocks. For example: server { listen 80 backlog=1024; server_name foo; ... } server { listen 80; server_name bar; ... } server { listen 80; server_name bazz; ... } The address part of the syntax ("address[:port]" / "port" / "unix:path") uniquely identifies the listening socket, and therefore is enough for name-based virtual servers (to let nginx know that the virtual server accepts requests on the listening socket in question). To ensure that listening options do not conflict between virtual servers, they were allowed only once. For example, the following configuration will be rejected ("duplicate listen options for 0.0.0.0:80 in ..."): server { listen 80 backlog=1024; server_name foo; ... } server { listen 80 backlog=512; server_name bar; ... } At some point it was, however, noticed, that it is sometimes convenient to repeat some options for clarity. In nginx 0.8.51 the "ssl" parameter was allowed to be specified multiple times, e.g.: server { listen 443 ssl backlog=1024; server_name foo; ... } server { listen 443 ssl; server_name bar; ... } server { listen 443 ssl; server_name bazz; ... } This approach makes configuration more readable, since SSL sockets are immediately visible in the configuration. If this is not needed, just the address can still be used. Later, additional protocol-specific options similar to "ssl" were introduced, notably "http2" and "proxy_protocol". With these options, one can write: server { listen 443 ssl backlog=1024; server_name foo; ... } server { listen 443 http2; server_name bar; ... } server { listen 443 proxy_protocol; server_name bazz; ... } The resulting socket will use ssl, http2, and proxy_protocol, but this is not really obvious from the configuration. To emphasize such misleading configurations are discouraged, nginx now warns as long as the "listen" directive is used with options different from the options previously used if this is potentially confusing. In particular, the following configurations are allowed: server { listen 8401 ssl backlog=1024; server_name foo; } server { listen 8401 ssl; server_name bar; } server { listen 8401 ssl; server_name bazz; } server { listen 8402 ssl http2 backlog=1024; server_name foo; } server { listen 8402 ssl; server_name bar; } server { listen 8402 ssl; server_name bazz; } server { listen 8403 ssl; server_name bar; } server { listen 8403 ssl; server_name bazz; } server { listen 8403 ssl http2; server_name foo; } server { listen 8404 ssl http2 backlog=1024; server_name foo; } server { listen 8404 http2; server_name bar; } server { listen 8404 http2; server_name bazz; } server { listen 8405 ssl http2 backlog=1024; server_name foo; } server { listen 8405 ssl http2; server_name bar; } server { listen 8405 ssl http2; server_name bazz; } server { listen 8406 ssl; server_name foo; } server { listen 8406; server_name bar; } server { listen 8406; server_name bazz; } And the following configurations will generate warnings: server { listen 8501 ssl http2 backlog=1024; server_name foo; } server { listen 8501 http2; server_name bar; } server { listen 8501 ssl; server_name bazz; } server { listen 8502 backlog=1024; server_name foo; } server { listen 8502 ssl; server_name bar; } server { listen 8503 ssl; server_name foo; } server { listen 8503 http2; server_name bar; } server { listen 8504 ssl; server_name foo; } server { listen 8504 http2; server_name bar; } server { listen 8504 proxy_protocol; server_name bazz; } server { listen 8505 ssl http2 proxy_protocol; server_name foo; } server { listen 8505 ssl http2; server_name bar; } server { listen 8505 ssl; server_name bazz; } server { listen 8506 ssl http2; server_name foo; } server { listen 8506 ssl; server_name bar; } server { listen 8506; server_name bazz; } server { listen 8507 ssl; server_name bar; } server { listen 8507; server_name bazz; } server { listen 8507 ssl http2; server_name foo; } server { listen 8508 ssl; server_name bar; } server { listen 8508; server_name bazz; } server { listen 8508 ssl backlog=1024; server_name foo; } server { listen 8509; server_name bazz; } server { listen 8509 ssl; server_name bar; } server { listen 8509 ssl backlog=1024; server_name foo; } The basic idea is that at most two sets of protocol options are allowed: the main one (with socket options, if any), and a shorter one, with options being a subset of the main options, repeated for clarity. As long as the shorter set of protocol options is used, all listen directives except the main one should use it.
author Maxim Dounin <mdounin@mdounin.ru>
date Sat, 28 Jan 2023 01:29:45 +0300
parents a6d116645c51
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2985
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
2 # Copyright (C) Igor Sysoev
4412
d620f497c50f Copyright updated.
Maxim Konovalov <maxim@nginx.com>
parents: 2985
diff changeset
3 # Copyright (C) Nginx, Inc.
2985
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
4
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
5
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
6 ngx_feature="GeoIP library"
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
7 ngx_feature_name=
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
8 ngx_feature_run=no
5014
210b66a6fc7f Configure: fixed GeoIP library detection.
Ruslan Ermilov <ru@nginx.com>
parents: 5013
diff changeset
9 ngx_feature_incs="#include <GeoIP.h>"
2985
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
10 ngx_feature_path=
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
11 ngx_feature_libs="-lGeoIP"
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
12 ngx_feature_test="GeoIP_open(NULL, 0)"
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
13 . auto/feature
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
14
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
15
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
16 if [ $ngx_found = no ]; then
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
17
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
18 # FreeBSD port
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
19
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
20 ngx_feature="GeoIP library in /usr/local/"
5014
210b66a6fc7f Configure: fixed GeoIP library detection.
Ruslan Ermilov <ru@nginx.com>
parents: 5013
diff changeset
21 ngx_feature_path="/usr/local/include"
2985
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
22
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
23 if [ $NGX_RPATH = YES ]; then
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
24 ngx_feature_libs="-R/usr/local/lib -L/usr/local/lib -lGeoIP"
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
25 else
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
26 ngx_feature_libs="-L/usr/local/lib -lGeoIP"
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
27 fi
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
28
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
29 . auto/feature
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
30 fi
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
31
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
32
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
33 if [ $ngx_found = no ]; then
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
34
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
35 # NetBSD port
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
36
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
37 ngx_feature="GeoIP library in /usr/pkg/"
5013
82a3f951feb3 Configure: fixed style of include directories.
Ruslan Ermilov <ru@nginx.com>
parents: 4412
diff changeset
38 ngx_feature_path="/usr/pkg/include"
2985
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
39
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
40 if [ $NGX_RPATH = YES ]; then
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
41 ngx_feature_libs="-R/usr/pkg/lib -L/usr/pkg/lib -lGeoIP"
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
42 else
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
43 ngx_feature_libs="-L/usr/pkg/lib -lGeoIP"
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
44 fi
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
45
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
46 . auto/feature
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
47 fi
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
48
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
49
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
50 if [ $ngx_found = no ]; then
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
51
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
52 # MacPorts
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
53
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
54 ngx_feature="GeoIP library in /opt/local/"
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
55 ngx_feature_path="/opt/local/include"
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
56
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
57 if [ $NGX_RPATH = YES ]; then
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
58 ngx_feature_libs="-R/opt/local/lib -L/opt/local/lib -lGeoIP"
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
59 else
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
60 ngx_feature_libs="-L/opt/local/lib -lGeoIP"
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
61 fi
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
62
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
63 . auto/feature
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
64 fi
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
65
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
66
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
67 if [ $ngx_found = yes ]; then
5014
210b66a6fc7f Configure: fixed GeoIP library detection.
Ruslan Ermilov <ru@nginx.com>
parents: 5013
diff changeset
68
210b66a6fc7f Configure: fixed GeoIP library detection.
Ruslan Ermilov <ru@nginx.com>
parents: 5013
diff changeset
69 CORE_INCS="$CORE_INCS $ngx_feature_path"
6383
85dea406e18f Dynamic modules.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5015
diff changeset
70
85dea406e18f Dynamic modules.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5015
diff changeset
71 if [ $USE_GEOIP = YES ]; then
85dea406e18f Dynamic modules.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5015
diff changeset
72 CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
85dea406e18f Dynamic modules.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5015
diff changeset
73 fi
85dea406e18f Dynamic modules.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5015
diff changeset
74
85dea406e18f Dynamic modules.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5015
diff changeset
75 NGX_LIB_GEOIP=$ngx_feature_libs
2985
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
76
6724
a6d116645c51 Configure: removed the --with-ipv6 option.
Maxim Dounin <mdounin@mdounin.ru>
parents: 6383
diff changeset
77 ngx_feature="GeoIP IPv6 support"
a6d116645c51 Configure: removed the --with-ipv6 option.
Maxim Dounin <mdounin@mdounin.ru>
parents: 6383
diff changeset
78 ngx_feature_name="NGX_HAVE_GEOIP_V6"
a6d116645c51 Configure: removed the --with-ipv6 option.
Maxim Dounin <mdounin@mdounin.ru>
parents: 6383
diff changeset
79 ngx_feature_run=no
a6d116645c51 Configure: removed the --with-ipv6 option.
Maxim Dounin <mdounin@mdounin.ru>
parents: 6383
diff changeset
80 ngx_feature_incs="#include <stdio.h>
a6d116645c51 Configure: removed the --with-ipv6 option.
Maxim Dounin <mdounin@mdounin.ru>
parents: 6383
diff changeset
81 #include <GeoIP.h>"
a6d116645c51 Configure: removed the --with-ipv6 option.
Maxim Dounin <mdounin@mdounin.ru>
parents: 6383
diff changeset
82 #ngx_feature_path=
a6d116645c51 Configure: removed the --with-ipv6 option.
Maxim Dounin <mdounin@mdounin.ru>
parents: 6383
diff changeset
83 #ngx_feature_libs=
a6d116645c51 Configure: removed the --with-ipv6 option.
Maxim Dounin <mdounin@mdounin.ru>
parents: 6383
diff changeset
84 ngx_feature_test="printf(\"%d\", GEOIP_CITY_EDITION_REV0_V6);"
a6d116645c51 Configure: removed the --with-ipv6 option.
Maxim Dounin <mdounin@mdounin.ru>
parents: 6383
diff changeset
85 . auto/feature
5015
a74d211f034d GeoIP: IPv6 support.
Ruslan Ermilov <ru@nginx.com>
parents: 5014
diff changeset
86
2985
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
87 else
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
88
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
89 cat << END
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
90
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
91 $0: error: the GeoIP module requires the GeoIP library.
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
92 You can either do not enable the module or install the library.
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
93
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
94 END
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
95
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
96 exit 1
31af2d1a742e ngx_http_geoip_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
97 fi