Subscribe Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security. Subscribe

Testrail behind nginx reverse proxy (problem with attaching files)

Hi!

We have TestRail server v6.1.0.4369 installation from official Docker images (testrail/apache, testrail/mysql) on dedicated virtual machine.
On another virtual machine we have nginx reverse proxy (proxy_pass) with SSL.
All users connect to nginx reverse proxy and login to development/testing systems, including TestRail.
Everything is ok with all systems, and TestRail is working fine, but we get errors when we trying to attach files to TestRail cases using TestRail UI.
We can upload large file (more than 50 MB) to other systems (jira, confluence, artifactory, etc …), but we have problem with Testrail.
When we trying to attach file to case directly in TestRail (without nginx reverse proxy), files uploading without problems.
We tried many nginx configurations, sometimes we can successfully upload one 15 MB file, but next uploads of 15 MB file freezes and then we get error “504 Gateway timeout”

For example:

  1. Configuration with enabled buffers (this configuration successfully working with our other systems with successfull uploading large file over 50 MB):
    server
    {
    server_tokens off;
    listen 80;
    server_name mytestrail.cloud;
    return 301 https://mytestrail.cloud$request_uri;
    }
    server
    {
    listen 443 ssl http2;
    server_tokens off;
    server_name mytestrail.cloud;
    ssl_certificate /etc/letsencrypt/live/mytestrail.cloud/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/mytestrail.cloud/privkey.pem;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
    location /
    {
    allow all;
    proxy_pass http://testrail.backend:8000;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto https;
    proxy_set_header X-Real-IP $remote_addr;
    client_max_body_size 100M;
    proxy_buffer_size 32768k;
    proxy_buffers 32 16384k;
    proxy_max_temp_file_size 15120m;
    client_body_buffer_size 16384k;
    proxy_buffering on;
    }
    }

  2. Then we turned off buffering, enabled HTTP/1.1 for proxy, upstream with keepalive, disabled client_max_body_size, buffers:

upstream backend {
server 123.45.6.78:8000;

keepalive 32;
}

server
{
server_tokens off;
listen 80;
server_name mytestrail.cloud;
client_body_timeout 300s;
client_header_timeout 300s;

location /
{
allow all;
proxy_pass http://backend;
proxy_http_version 1.1;
proxy_set_header Connection “”;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_cache off;
client_body_buffer_size 100M;
client_max_body_size 100M;
proxy_request_buffering off;
}
}

But we always had “504 Gateway timeout” when we upload files, usually when uploading a second file.

Our Environment:
Server1 (backend):
TestRail v6.1.0.4369 (docker images testrail/apache, testrail/mysql).

php.ini:
zend_extension=/opt/ioncube/ioncube_loader_lin_7.2.so
post_max_size=64M
upload_max_filesize=64M

I checked parameters by php -i command:
file_uploads => On => On
max_file_uploads => 20 => 20
upload_max_filesize => 64M => 64M
post_max_size => 64M => 64M
Server2 (reverse proxy):
nginx 1.16.0 with reverse proxy and SSL enabled.

Maybe someone have experience with testrail behind nginx reverse proxy.
Thanks!