Skip to content

Commit 5dd3aca

Browse files
balasankarcDanDan
committed
Merge branch 'fix-416803-bad-gateway-on-large-artifacts' into 'master'
Don't 500 when pages tries to serve a chunked file See merge request https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/7006 Merged-by: Balasankar 'Balu' C <[email protected]> Approved-by: Clemens Beck <[email protected]> Reviewed-by: Dan <[email protected]> Co-authored-by: Dan <[email protected]> Co-authored-by: Dan <[email protected]>
2 parents e8bb7c8 + 621e2c5 commit 5dd3aca

File tree

6 files changed

+22
-0
lines changed

6 files changed

+22
-0
lines changed

doc/settings/nginx.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ This inserts the defined string into the end of the `server` block of
334334

335335
```conf
336336
proxy_cache off;
337+
proxy_http_version 1.1;
337338
proxy_pass http://gitlab-workhorse;
338339
```
339340

@@ -533,6 +534,7 @@ server {
533534
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
534535
proxy_set_header X-Forwarded-Proto $scheme;
535536
537+
proxy_http_version 1.1;
536538
proxy_pass http://gitlab-workhorse;
537539
538540
## The following settings only work with NGINX 1.7.11 or newer
@@ -556,6 +558,7 @@ server {
556558
557559
## To access Grafana
558560
location /-/grafana/ {
561+
proxy_http_version 1.1;
559562
proxy_pass http://localhost:3000/;
560563
}
561564

files/gitlab-cookbooks/gitlab/templates/default/nginx-gitlab-health.conf.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ location /error.json {
1515
<% @monitoring_addresses.each do |address| %>
1616
location = <%= File.join(@path, address[:url]) %> {
1717
proxy_cache off;
18+
proxy_http_version 1.1;
1819
proxy_pass http://gitlab-workhorse;
1920
error_page 404 500 502 /error.<%= address[:format] %>;
2021
}

files/gitlab-cookbooks/gitlab/templates/default/nginx-gitlab-mattermost-http.conf.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ server { ## HTTPS server
130130
proxy_connect_timeout 90;
131131
proxy_send_timeout 300;
132132
proxy_read_timeout <%= @proxy_read_timeout %>;
133+
proxy_http_version 1.1;
133134

134135
proxy_pass http://gitlab_mattermost;
135136
}
@@ -157,6 +158,7 @@ server { ## HTTPS server
157158
<% next if header[1].nil? %>
158159
proxy_set_header <%= header[0] %> <%= header[1] %>;
159160
<% end %>
161+
proxy_http_version 1.1;
160162

161163
proxy_pass http://gitlab_mattermost;
162164
}

files/gitlab-cookbooks/gitlab/templates/default/nginx-gitlab-pages-http.conf.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ server {
111111
proxy_buffer_size <%= @proxy_custom_buffer_size %>;
112112
<% end -%>
113113

114+
proxy_http_version 1.1;
114115
proxy_pass http://<%= @pages_listen_proxy %>;
115116
}
116117

files/gitlab-cookbooks/gitlab/templates/default/nginx-status.conf.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ server {
3737

3838
location /rails-metrics {
3939
proxy_cache off;
40+
proxy_http_version 1.1;
4041
proxy_pass http://gitlab-workhorse/-/metrics;
4142
<% @options.each do |key, value|
4243
if value.is_a?(String) -%>

spec/chef/cookbooks/gitlab/recipes/nginx_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,16 @@
418418
end
419419
end
420420
end
421+
422+
# Required to allow chunked encoding responses as of nginx 1.23
423+
# https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/7006
424+
it 'sets proxy_http_version 1.1 when proxy_pass is used' do
425+
http_conf.each_value do |conf|
426+
expect(chef_run).to render_file(conf).with_content { |content|
427+
expect(content).to include('proxy_http_version 1.1;') if content.include?('proxy_pass')
428+
}
429+
end
430+
end
421431
end
422432

423433
context 'when is enabled' do
@@ -565,6 +575,7 @@
565575
expect(chef_run).to render_file(http_conf['gitlab']).with_content { |content|
566576
expect(content).to include('location /-/grafana/ {')
567577
expect(content).to include('proxy_pass http://localhost:3000/;')
578+
expect(content).to include('proxy_http_version 1.1;')
568579
}
569580
end
570581
end
@@ -580,6 +591,7 @@
580591
expect(chef_run).to render_file(http_conf['gitlab']).with_content { |content|
581592
expect(content).to include('location = /-/kubernetes-agent/ {')
582593
expect(content).to include('proxy_pass http://localhost:8150/;')
594+
expect(content).to include('proxy_http_version 1.1;')
583595

584596
expect(content).to include('location /-/kubernetes-agent/k8s-proxy/ {')
585597
expect(content).to include('proxy_pass http://localhost:8154/;')
@@ -601,6 +613,7 @@
601613
expect(chef_run).to render_file(http_conf['gitlab']).with_content { |content|
602614
expect(content).to include('location = /-/kubernetes-agent/ {')
603615
expect(content).to include('proxy_pass http://localhost:8150/;')
616+
expect(content).to include('proxy_http_version 1.1;')
604617

605618
expect(content).to include('location /-/kubernetes-agent/k8s-proxy/ {')
606619
expect(content).to include('proxy_pass http://localhost:8154/;')
@@ -614,6 +627,7 @@
614627

615628
expect(content).to include('proxy_http_version 1.1;')
616629
expect(content).to include('proxy_pass http://localhost:8150/;')
630+
expect(content).to include('proxy_http_version 1.1;')
617631

618632
expect(content).to include('location /k8s-proxy/ {')
619633
expect(content).to include('location = /k8s-proxy/ {')

0 commit comments

Comments
 (0)