cscg24-njs

CSCG 2024 Challenge 'Nimble Join Service'
git clone https://git.sinitax.com/sinitax/cscg24-njs
Log | Files | Refs | sfeed.txt

nginx.conf (1571B)


      1worker_processes  1;
      2
      3# Import njs module
      4# https://nginx.org/en/docs/njs/
      5load_module modules/ngx_http_js_module.so;
      6
      7events {
      8    worker_connections  1024;
      9}
     10
     11
     12http {
     13    # Import custom njs script
     14    # Allows to join files together
     15    js_path "/etc/nginx/http/";
     16    js_import main from join.js;
     17
     18    root /usr/share/nginx/html/;
     19
     20    server {
     21        listen       1024;
     22
     23        # Serve index
     24        location / {
     25        }
     26
     27        # Nginx direct file upload using client_body_in_file_only
     28        # https://nginx.org/en/docs/http/ngx_http_core_module.html#client_body_in_file_only
     29        location /upload {
     30            limit_except POST              { deny all; }
     31            client_body_temp_path          /usr/share/nginx/html/data; 
     32            client_body_in_file_only       on;
     33            client_body_buffer_size        128K;
     34            client_max_body_size           50M;
     35            proxy_pass_request_headers     on;
     36            proxy_set_body                 $request_body_file;
     37            proxy_pass                     http://localhost:8080/upload;
     38            proxy_redirect                 off;
     39        }
     40
     41        # Allows to join multiple files
     42        # Either returns a string or binary data
     43        location /join {
     44            js_content main.join;
     45        }
     46
     47        # List all uploaded files
     48        location /data {
     49            autoindex on;
     50        }
     51
     52    }
     53
     54    # Backend server
     55    server {
     56        server_name localhost;
     57        listen       8080;
     58
     59        location /upload {
     60            return 200 "File uploaded";
     61        }
     62    }
     63}