Ticket #1359: nginx_map_with_proxy_bypass_behaviour

File nginx_map_with_proxy_bypass_behaviour, 8.2 KB (added by chazerbazer@…, 9 years ago)

nginx -V output. Also expected and actual curl output.

Line 
1Output of nginx -V:
2
3
4nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
5nginx: configuration file /etc/nginx/nginx.conf test is successful
6# configuration file /etc/nginx/nginx.conf:
7user nginx;
8worker_processes auto;
9error_log /var/log/nginx/error.log;
10pid /run/nginx.pid;
11
12include /usr/share/nginx/modules/*.conf;
13
14events {
15 worker_connections 1024;
16}
17
18http {
19 log_format main '$remote_addr - $remote_user [$time_local] "$request" '
20 '$status $body_bytes_sent "$http_referer" '
21 '"$http_user_agent" "$http_x_forwarded_for"';
22
23 access_log /var/log/nginx/access.log main;
24
25 sendfile on;
26 tcp_nopush on;
27 tcp_nodelay on;
28 keepalive_timeout 65;
29 types_hash_max_size 2048;
30
31 include /etc/nginx/mime.types;
32 default_type application/octet-stream;
33
34 include /etc/nginx/conf.d/*.conf;
35
36 map $upstream_http_cache_control $bypass_cache_control {
37 "max-age=60" 1;
38 default 0;
39 }
40
41 proxy_cache_path /tmp/gtm_cache_data levels=1:2 use_temp_path=on keys_zone=my_zone:10m inactive=2m;
42 proxy_temp_path /tmp/gtm_cache_tmp;
43 proxy_cache_key "$scheme$request_method$host$request_uri";
44
45 server {
46 listen 80 default_server;
47 server_name my_default_nginx_proxy;
48
49 location / {
50
51 add_header upstream_http_cache_control ":$upstream_http_cache_control:";
52 add_header Mapped_Cache-Control $bypass_cache_control;
53 add_header X-Proxy-Cache $upstream_cache_status;
54
55 proxy_cache my_zone;
56 proxy_cache_min_uses 0;
57 proxy_cache_bypass $bypass_cache_control;
58
59 include proxy_params;
60 proxy_pass http://localhost:9000/;
61 include /etc/nginx/mime.types;
62 proxy_set_header Host $host;
63
64 }
65
66 }
67
68 server {
69 listen 9000;
70 server_name _;
71 location / {
72 add_header Cache-Control "max-age=60";
73 return 200;
74 }
75
76 }
77
78}
79
80# configuration file /etc/nginx/mime.types:
81
82types {
83 text/html html htm shtml;
84 text/css css;
85 text/xml xml;
86 image/gif gif;
87 image/jpeg jpeg jpg;
88 application/javascript js;
89 application/atom+xml atom;
90 application/rss+xml rss;
91
92 text/mathml mml;
93 text/plain txt;
94 text/vnd.sun.j2me.app-descriptor jad;
95 text/vnd.wap.wml wml;
96 text/x-component htc;
97
98 image/png png;
99 image/tiff tif tiff;
100 image/vnd.wap.wbmp wbmp;
101 image/x-icon ico;
102 image/x-jng jng;
103 image/x-ms-bmp bmp;
104 image/svg+xml svg svgz;
105 image/webp webp;
106
107 application/font-woff woff;
108 application/java-archive jar war ear;
109 application/json json;
110 application/mac-binhex40 hqx;
111 application/msword doc;
112 application/pdf pdf;
113 application/postscript ps eps ai;
114 application/rtf rtf;
115 application/vnd.apple.mpegurl m3u8;
116 application/vnd.ms-excel xls;
117 application/vnd.ms-fontobject eot;
118 application/vnd.ms-powerpoint ppt;
119 application/vnd.wap.wmlc wmlc;
120 application/vnd.google-earth.kml+xml kml;
121 application/vnd.google-earth.kmz kmz;
122 application/x-7z-compressed 7z;
123 application/x-cocoa cco;
124 application/x-java-archive-diff jardiff;
125 application/x-java-jnlp-file jnlp;
126 application/x-makeself run;
127 application/x-perl pl pm;
128 application/x-pilot prc pdb;
129 application/x-rar-compressed rar;
130 application/x-redhat-package-manager rpm;
131 application/x-sea sea;
132 application/x-shockwave-flash swf;
133 application/x-stuffit sit;
134 application/x-tcl tcl tk;
135 application/x-x509-ca-cert der pem crt;
136 application/x-xpinstall xpi;
137 application/xhtml+xml xhtml;
138 application/xspf+xml xspf;
139 application/zip zip;
140
141 application/octet-stream bin exe dll;
142 application/octet-stream deb;
143 application/octet-stream dmg;
144 application/octet-stream iso img;
145 application/octet-stream msi msp msm;
146
147 application/vnd.openxmlformats-officedocument.wordprocessingml.document docx;
148 application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx;
149 application/vnd.openxmlformats-officedocument.presentationml.presentation pptx;
150
151 audio/midi mid midi kar;
152 audio/mpeg mp3;
153 audio/ogg ogg;
154 audio/x-m4a m4a;
155 audio/x-realaudio ra;
156
157 video/3gpp 3gpp 3gp;
158 video/mp2t ts;
159 video/mp4 mp4;
160 video/mpeg mpeg mpg;
161 video/quicktime mov;
162 video/webm webm;
163 video/x-flv flv;
164 video/x-m4v m4v;
165 video/x-mng mng;
166 video/x-ms-asf asx asf;
167 video/x-ms-wmv wmv;
168 video/x-msvideo avi;
169}
170
171# configuration file /etc/nginx/conf.d/default.conf:
172server {
173 listen 80;
174 server_name localhost;
175
176 #charset koi8-r;
177 #access_log /var/log/nginx/host.access.log main;
178
179 location / {
180 root /usr/share/nginx/html;
181 index index.html index.htm;
182 }
183
184 #error_page 404 /404.html;
185
186 # redirect server error pages to the static page /50x.html
187 #
188 error_page 500 502 503 504 /50x.html;
189 location = /50x.html {
190 root /usr/share/nginx/html;
191 }
192
193 # proxy the PHP scripts to Apache listening on 127.0.0.1:80
194 #
195 #location ~ \.php$ {
196 # proxy_pass http://127.0.0.1;
197 #}
198
199 # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
200 #
201 #location ~ \.php$ {
202 # root html;
203 # fastcgi_pass 127.0.0.1:9000;
204 # fastcgi_index index.php;
205 # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
206 # include fastcgi_params;
207 #}
208
209 # deny access to .htaccess files, if Apache's document root
210 # concurs with nginx's one
211 #
212 #location ~ /\.ht {
213 # deny all;
214 #}
215}
216
217
218# configuration file /etc/nginx/proxy_params:
219proxy_set_header Host $host;
220proxy_set_header X-Real-IP $remote_addr;
221proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
222
223client_max_body_size 100M;
224client_body_buffer_size 1m;
225proxy_intercept_errors on;
226proxy_buffering on;
227proxy_buffer_size 128k;
228proxy_buffers 256 16k;
229proxy_busy_buffers_size 256k;
230proxy_temp_file_write_size 256k;
231proxy_max_temp_file_size 0;
232proxy_read_timeout 300;
233proxy_headers_hash_bucket_size 1024;
234
235
236
237Actual result from client:
238curl --head http://playpen02/benula/Aldjia.jpg
239HTTP/1.1 200 OK
240Server: nginx/1.13.4
241Date: Thu, 17 Aug 2017 15:28:33 GMT
242Content-Type: image/jpeg
243Content-Length: 0
244Connection: keep-alive
245Cache-Control: max-age=60
246upstream_http_cache_control: :max-age=60:
247Mapped_Cache-Control: 0
248X-Proxy-Cache: HIT
249
250Expected result from client:
251$ curl --head http://playpen02/benula/Aldjia.jpg
252HTTP/1.1 200 OK
253Server: nginx/1.13.4
254Date: Thu, 17 Aug 2017 15:32:17 GMT
255Content-Type: image/jpeg
256Content-Length: 0
257Connection: keep-alive
258Cache-Control: max-age=60
259upstream_http_cache_control: :max-age=60:
260Mapped_Cache-Control: 1
261X-Proxy-Cache: BYPASS
262
263
264
265
266