0rtt-anti-replay.conf 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. # Implement TLS 1.3 0-RTT anti-replay for NGINX
  2. # Requires: NGINX directive "ssl_early_data" on
  3. # Usage:
  4. # Make sure these "map" blocks are included in "http" block
  5. # Put the following two lines in SSL "server" block, before any "location" blocks
  6. # if ($anti_replay = 307) { return 307 https://$host$request_uri; }
  7. # if ($anti_replay = 425) { return 425; }
  8. # Pass "Early-Data" header to backend/upstream
  9. # Only for 0-RTT requests from clients that understand 425 status code (RFC 8470)
  10. # fastcgi_param HTTP_EARLY_DATA $rfc_early_data if_not_empty;
  11. # proxy_set_header Early-Data $rfc_early_data;
  12. # Copyright © myrevery
  13. # Copyright © 7677333 (An anagram of a Anonymous Cybersecurity Research Team)
  14. map "$request_method:$is_args" $ar_idempotent {
  15. default 0;
  16. "~^GET:$|^(HEAD|OPTIONS|TRACE):\?*$" 1;
  17. }
  18. map $http_user_agent $ar_support_425 {
  19. default 0;
  20. "~Firefox/((58|59)|([6-9]\d)|([1-9]\d{2,}))\.\d+" 1;
  21. }
  22. map "$ssl_early_data:$ar_idempotent:$ar_support_425" $anti_replay {
  23. 1:0:0 307;
  24. 1:0:1 425;
  25. }
  26. map "$ssl_early_data:$ar_support_425" $rfc_early_data {
  27. 1:1 1;
  28. }