Skip to content

Commit a60f90c

Browse files
R68801 gzip nginx cloudfront pr 2.x (#1544)
* r68801-r67628-gzip-nginx-cloudfront * r68801-r67628-gzip-nginx-cloudfront * remove test tasks * remove test tasks * remove test tasks
1 parent ee3723a commit a60f90c

File tree

5 files changed

+20
-16
lines changed

5 files changed

+20
-16
lines changed

roles/debian/nginx/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ nginx:
6060
# on_calendar: "Mon *-*-* 04:00:00"
6161
ratelimitingcrawlers: true
6262
is_default: true
63+
is_behind_cloudfront: false # set to true to disable gzip.
6364
basic_auth:
6465
auth_enabled: false
6566
auth_file: "" # optionally provide the path on the deploy server to a htpasswd file - WARNING - it must be valid and will not be checked!

roles/debian/nginx/tasks/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
force: true
5353
with_items:
5454
- _common
55+
- _common_cloudfront
5556
- custom
5657
- docker_registry
5758
- drupal_common
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
### {{ ansible_managed }}
2+
3+
gzip off;
4+
proxy_buffer_size 512k;
5+
proxy_buffers 8 256k;
6+
client_body_buffer_size 512k;
7+
fastcgi_buffer_size 512k ;
8+
fastcgi_buffers 8 256k ;
9+
client_max_body_size {{ nginx.client_max_body_size }} ;
10+
# Disable content sniffing, since it's an attack vector.
11+
add_header X-Content-Type-Options nosniff;

roles/debian/nginx/templates/nginx.conf.j2

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ http {
2323

2424
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
2525
'$status $body_bytes_sent "$http_referer" '
26-
'"$http_user_agent" $request_length $body_bytes_sent';
26+
'"$http_user_agent" $request_length';
2727

2828
log_format proxy '$http_x_forwarded_for - $remote_user [$time_local] "$request" '
2929
'$status $body_bytes_sent "$http_referer" '
30-
'"$http_user_agent" $request_length $body_bytes_sent';
30+
'"$http_user_agent" $request_length';
3131

3232
server_names_hash_bucket_size {{ nginx.http.server_names_hash_bucket_size }};
3333
# server_name_in_redirect off;
@@ -50,22 +50,9 @@ http {
5050
error_log {{ nginx.http.error_log }};
5151

5252
##
53-
# Gzip Settings
53+
# Additional Settings
5454
##
5555

56-
gzip on;
57-
58-
# gzip_vary on;
59-
# gzip_proxied any;
60-
# gzip_comp_level 6;
61-
# gzip_buffers 16 8k;
62-
# gzip_http_version 1.1;
63-
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
64-
65-
##
66-
# Additional Settings
67-
##
68-
6956
{% if nginx.http.custom_directives is defined %}
7057
{% for directive in nginx.http.custom_directives %}
7158
{{ directive }}

roles/debian/nginx/templates/vhosts.j2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ server {
2828
access_log {{ domain.access_log }} {{ domain.access_log_format | default('main') }};
2929
root "{{ domain.webroot }}";
3030
include "/etc/nginx/conf.d/{{ domain.project_type }}";
31+
{% if domain.is_behind_cloudfront is defined and domain.is_behind_cloudfront %}
32+
include "/etc/nginx/conf.d/_common_cloudfront";
33+
{% else %}
3134
include "/etc/nginx/conf.d/_common";
35+
{% endif %}
3236
{% if domain.ssl is defined and domain.ssl.handling == 'letsencrypt' %}
3337
{% if domain.ssl.web_server | default('standalone') == 'standalone' %}
3438
# Proxy for certbot (LetsEncrypt)

0 commit comments

Comments
 (0)