nginx.conf 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # Restrict access to the website by IP or wrong domain name) and return 400
  2. server {
  3. listen unix:/dev/shm/h1.sock proxy_protocol default_server;
  4. listen unix:/dev/shm/h2c.sock http2 proxy_protocol default_server;
  5. set_real_ip_from unix:;
  6. real_ip_header proxy_protocol;
  7. server_name _;
  8. return 400;
  9. }
  10. # HTTP1 UDS listener
  11. server {
  12. listen unix:/dev/shm/h1.sock proxy_protocol; # HTTP/1.1 server monitor process and enable PROXY protocol reception
  13. set_real_ip_from unix:;
  14. real_ip_header proxy_protocol;
  15. server_name example.com behindcdn.com; # Change to your own domain name(s)
  16. location / {
  17. add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; # enable HSTS
  18. root /var/www/html; # Modify to the path of the WEB file stored by yourself (check the permissions)
  19. index index.html index.htm;
  20. }
  21. }
  22. # HTTP2 UDS listener
  23. server {
  24. listen unix:/dev/shm/h2c.sock http2 proxy_protocol; # H2C server monitor process and enable PROXY protocol reception
  25. set_real_ip_from unix:;
  26. real_ip_header proxy_protocol;
  27. server_name example.com behindcdn.com; # Change to your own domain name(s) (don't forget to add the certificates to xray config)
  28. # grpc settings
  29. grpc_read_timeout 1h;
  30. grpc_send_timeout 1h;
  31. grpc_set_header X-Real-IP $remote_addr;
  32. # Decoy website
  33. location / {
  34. add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; # enable HSTS
  35. root /var/www/html; # Modify to the path of the WEB file stored by yourself (check the permissions)
  36. index index.html index.htm;
  37. }
  38. location /trgrpc { #corresponds to serviceName in trojan-grpc config of xray
  39. # POST returns 404 when negotiation fails
  40. if ($request_method != "POST") {
  41. return 404;
  42. }
  43. client_body_buffer_size 1m;
  44. client_body_timeout 1h;
  45. client_max_body_size 0;
  46. grpc_pass grpc://127.0.0.1:3001;
  47. }
  48. location /vlgrpc { # corresponds to serviceName in vless-grpc config of xray
  49. # return 404 if HTTP Method is not POST
  50. if ($request_method != "POST") {
  51. return 404;
  52. }
  53. client_body_buffer_size 1m;
  54. client_body_timeout 1h;
  55. client_max_body_size 0;
  56. grpc_pass grpc://127.0.0.1:3002;
  57. }
  58. location /vmgrpc { # corresponds to serviceName in vmess-grpc config of xray
  59. # return 404 if HTTP Method is not POST
  60. if ($request_method != "POST") {
  61. return 404;
  62. }
  63. client_body_buffer_size 1m;
  64. client_body_timeout 1h;
  65. client_max_body_size 0;
  66. grpc_pass grpc://127.0.0.1:3003;
  67. }
  68. location /ssgrpc { # corresponds to serviceName in shadowsocks-grpc config of xray
  69. # return 404 if HTTP Method is not POST
  70. if ($request_method != "POST") {
  71. return 404;
  72. }
  73. client_body_buffer_size 1m;
  74. client_body_timeout 1h;
  75. client_max_body_size 0;
  76. grpc_pass grpc://127.0.0.1:3004;
  77. }
  78. }