# nginx site for the locust issue tracker (package locust).
#
# Enable it with
#     ln -s ../sites-available/locust /etc/nginx/sites-enabled/locust
#     systemctl reload nginx
# after setting server_name below.  It serves plain HTTP; for HTTPS, run
#     certbot --nginx -d bugs.example.org
# or use the commented server block at the end, and set BASE_URL in
# /etc/locust/locust.conf to the https:// address (dpkg-reconfigure locust).

upstream locust {
    server 127.0.0.1:8080;
    keepalive 16;
}

server {
    listen 80;
    listen [::]:80;
    server_name bugs.example.org;

    # Above the tracker's MAX_FILE_SIZE ([locust-mantis] in locust.conf), plus the
    # form around the file.
    client_max_body_size 16m;

    location / {
        proxy_pass http://locust;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_read_timeout 300s;
        # Exports and attachments are streamed as they are produced.
        proxy_buffering off;
        # The buffer the response header is read into; a page that lists
        # issues sets a cookie naming each of them, and nginx answers 502
        # when the header does not fit (the default is one page, 4k).
        proxy_buffer_size 16k;
    }
}

# HTTPS with your own certificate (or ssl-cert's self-signed one, for a
# first test):
#
# server {
#     listen 80;
#     listen [::]:80;
#     server_name bugs.example.org;
#     return 301 https://$host$request_uri;
# }
#
# server {
#     listen 443 ssl;
#     listen [::]:443 ssl;
#     http2 on;
#     server_name bugs.example.org;
#     ssl_certificate     /etc/ssl/certs/ssl-cert-snakeoil.pem;
#     ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key;
#     add_header Strict-Transport-Security "max-age=31536000" always;
#     client_max_body_size 16m;
#     location / {
#         proxy_pass http://locust;
#         proxy_http_version 1.1;
#         proxy_set_header Connection "";
#         proxy_set_header Host $host;
#         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#         proxy_set_header X-Forwarded-Proto $scheme;
#         proxy_read_timeout 300s;
#         proxy_buffering off;
#         proxy_buffer_size 16k;
#     }
# }
