server {
  listen 443 ssl;
  listen [::]:443 ssl;
  
  ssl_certificate       /etc/v2ray/v2ray.crt;
  ssl_certificate_key   /etc/v2ray/v2ray.key;
  ssl_session_timeout 1d;
  ssl_session_cache shared:MozSSL:10m;
  ssl_session_tickets off;
  
  ssl_protocols         TLSv1.2 TLSv1.3;
  ssl_ciphers           ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
  ssl_prefer_server_ciphers off;
  
  server_name           mydomain.me;
  location /michi/Tun { # This michi shall in consistent with the grpc serviceName in v2ray config.json
  
    if ($request_method != "POST") { # if the request method is not POST for this location, return 404
        return 404;
    }

    grpc_socket_keepalive on;
    grpc_intercept_errors on;
    grpc_pass grpc://127.0.0.1:12345; # presume v2ray is listening on port 12345 
    grpc_set_header Upgrade $http_upgrade;
    grpc_set_header Connection "upgrade";
    grpc_set_header Host $host;
    # Show real IP in v2ray access.log
    grpc_set_header X-Real-IP $remote_addr;
    grpc_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }
}