# Define fastcgi vars for roles\nginx\defaults\main.yml

**URL:** https://discourse.roots.io/t/define-fastcgi-vars-for-roles-nginx-defaults-main-yml/10731
**Category:** trellis
**Created:** 2017-10-24T20:49:27Z
**Posts:** 5

## Post 1 by @Ivan_Svaljek — 2017-10-24T20:49:28Z

I’ve got error 502, and it seems it’s due to small fastcgi buffers. Tested it by direct file edit on virtual machine, no more 502.

How to define the  
{{nginx\_fastcgi\_buffers}}  
{{nginx\_fastcgi\_buffer\_size}}  
that are used in nginx.conf.j2?

I tried defining them in group\_vars\all\main.yml but it didn’t affect /etc/nginx/nginx.conf in the virtual machine, not even after vagrant provision.

---

## Post 2 by @ben — 2017-10-24T21:00:25Z

> [@Ivan_Svaljek](#):
>
> I tried defining them in group\_vars\all\main.yml

Can you share exactly what you did?

---

## Post 3 by @Ivan_Svaljek — 2017-10-25T05:24:30Z

I added these two lines to group\_vars\all\main.yml  
nginx\_fastcgi\_buffers: 8 16k  
nginx\_fastcgi\_buffer\_size: 16k

And ran vagrant provision on host, and sudo service nginx restart in vbox.

---

## Post 4 by @fullyint — 2017-10-25T05:48:17Z

One potential for how this could happen relates to Ansible’s [variable precedence](https://docs.ansible.com/ansible/latest/playbooks_variables.html#variable-precedence-where-should-i-put-a-variable). Suppose you were to have these same variables defined in `group_vars/development/`. Such (unmodified) variables would override your modified variables in `group_vars/all/`. (Any particular group in `group_vars` will take precedence over the `all` group.)

You could search your Trellis files for other conflicting definitions of these vars, potentially even in [temp files](https://discourse.roots.io/t/misconfiguration-of-wordpress-site-names/9609/5). Of course, the values in `roles/nginx/defaults/main.yml` shouldn’t be conflicting because they have the lowest priority.

When working out variable precedence, it is often helpful to temporarily insert a `debug` task into the relevant task file or context, just to ensure you know what Ansible is using for variable values. Example:

```
- debug:
    msg: |
      nginx_fastcgi_buffers is `{{ nginx_fastcgi_buffers }}`
      nginx_fastcgi_buffer_size is `{{ nginx_fastcgi_buffer_size }}`
```

---

## Post 5 by @Ivan_Svaljek — 2017-10-25T06:01:18Z

Didn’t know about debug, thanks for the tip. Could it be due to empty line, between last default line in main.yml and my two lines?  
It seems removing the empty line and doing vagrant provision did the trick.
