Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save itsnikolayy/ad3d023b3702f1bfebc5853950eb224b to your computer and use it in GitHub Desktop.
Save itsnikolayy/ad3d023b3702f1bfebc5853950eb224b to your computer and use it in GitHub Desktop.
location ~ ^/restapi/(v\d+(\.\d+)?)/(.+)$ {
set $directive "RESTful File Handle";
limit_req zone=apilimit burst=10 nodelay;
upload_pass @rest;
upload_store /data/tmp/nginx_uploads 1;
upload_set_form_field $upload_field_name.name "$upload_file_name";
upload_set_form_field $upload_field_name.content_type "$upload_content_type";
upload_set_form_field $upload_field_name.path "$upload_tmp_path";
upload_set_form_field $upload_field_name.nginx_upload 1;
upload_pass_form_field ".*";
upload_pass_args on;
upload_store_access user:rw group:rw all:rw;
upload_max_output_body_len 0;
upload_buffer_size 16m;
upload_max_file_size 1000m;
client_max_body_size 1000m;
error_page 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 = @rest;
upload_cleanup 400-599;
set $api_path $3;
set $api_version $1;
}
location @rest {
set $directive "RESTful API";
gzip off;
fastcgi_pass unix:/var/run/fcgi_socket;
fastcgi_read_timeout 2400;
fastcgi_index rest.cgi;
fastcgi_param SCRIPT_FILENAME /var/www/cgi-bin/cgi-mod/rest.cgi;
fastcgi_param QUERY_STRING api_path=$api_path&$query_string&version=$api_version;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param SCRIPT_NAME rest.cgi;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI /cgi-mod/rest.cgi;
fastcgi_param ORIG_DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param HTTPS $https_on; #setting $ENV{HTTPS}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment