@@ -24,8 +24,22 @@ http {
2424
2525 server_tokens off;
2626
27+ log_format logfmtably
28+ 'nginx '
29+ 'request_time=$request_time '
30+ 'request_id=$http_x_request_id '
31+ 'status=$status '
32+ 'remote_addr=$remote_addr '
33+ 'remote_port=$remote_port '
34+ 'server_addr=$server_addr '
35+ 'bytes_sent=$bytes_sent body_bytes_sent=$body_bytes_sent '
36+ 'request_length=$request_length '
37+ 'scheme=$scheme request_method=$request_method '
38+ 'request_uri="$request_uri" host="$http_host" '
39+ 'referrer="$http_referer" user_agent="$http_user_agent" '
40+ 'content_type="$sent_http_content_type" accept="$http_accept"';
2741 log_format l2met 'measure#nginx.service=$request_time request_id=$http_x_request_id';
28- access_log <%= ENV['NGINX_ACCESS_LOG_PATH'] || 'logs/nginx/access.log' %> l2met ;
42+ access_log <%= ENV['NGINX_ACCESS_LOG_PATH'] || 'logs/nginx/access.log' %> logfmtably ;
2943 error_log <%= ENV['NGINX_ERROR_LOG_PATH'] || 'logs/nginx/error.log' %> notice;
3044
3145 include mime.types;
3953 map_hash_bucket_size 8192;
4054
4155 # Creates a map of redirects for us
42- map $uri $redirected_url {
56+ map $request_uri $redirected_url {
4357 default "none";
4458 include website-redirects.conf;
4559 include client-lib-development-guide-redirects.conf;
@@ -207,10 +221,10 @@ http {
207221 <% if content_request_protected %>
208222 # Serve the file if it exists, otherwise try to authenticate
209223 # (.html requests won't match here, they'll go to the @html_auth location)
210- try_files $uri @html_auth;
224+ try_files $request_uri @html_auth;
211225 <% else %>
212226 # Serve the file if it exists, try index.html for paths without a trailing slash, otherwise 404
213- try_files $uri $uri /index.html $uri / =404;
227+ try_files $request_uri $request_uri /index.html $request_uri / =404;
214228 <% end %>
215229 }
216230
@@ -222,14 +236,14 @@ http {
222236 # .html request without authentication, so handle it here by 404ing or redirecting to the canonical host
223237 # depending on whether CONTENT_REQUEST_CANONICAL_HOST is set or not
224238 <% if host = ENV['CONTENT_REQUEST_CANONICAL_HOST'] %>
225- return 301 <%= ENV['SKIP_HTTPS'] == 'true' ? '$scheme' : 'https' %> ://<%= host %> $uri ;
239+ return 301 <%= ENV['SKIP_HTTPS'] == 'true' ? '$scheme' : 'https' %> ://<%= host %> $request_uri ;
226240 <% else %>
227241 return 404;
228242 <% end %>
229243 }
230244
231245 # If the request is authenticated, break out of the location block and serve the file
232- try_files $uri .html $uri /index.html $uri / =404;
246+ try_files $request_uri .html $request_uri /index.html $request_uri / =404;
233247 }
234248
235249 # Don't serve files with the .html extension here, send them to the canonical location
@@ -242,7 +256,7 @@ http {
242256 # .html request without authentication, so handle it here by 404ing or redirecting to the canonical host
243257 # depending on whether CONTENT_REQUEST_CANONICAL_HOST is set or not
244258 <% if host = ENV['CONTENT_REQUEST_CANONICAL_HOST'] %>
245- return 301 <%= ENV['SKIP_HTTPS'] == 'true' ? '$scheme' : 'https' %> ://<%= host %> $uri ;
259+ return 301 <%= ENV['SKIP_HTTPS'] == 'true' ? '$scheme' : 'https' %> ://<%= host %> $request_uri ;
246260 <% else %>
247261 return 404;
248262 <% end %>
0 commit comments