Giter Site home page Giter Site logo

httpUpgrade issue about xray-core HOT 6 CLOSED

X-Oracle avatar X-Oracle commented on May 26, 2024
httpUpgrade issue

from xray-core.

Comments (6)

mmmray avatar mmmray commented on May 26, 2024 1

what is the code for the worker? cloudflare workers is not part of the example.

from xray-core.

Fangliding avatar Fangliding commented on May 26, 2024

try do delete ?ed=2560 in path

from xray-core.

X-Oracle avatar X-Oracle commented on May 26, 2024

try do delete ?ed=2560 in path

I tested both.
same result.

from xray-core.

X-Oracle avatar X-Oracle commented on May 26, 2024

I logged the headers my server receives from Cloudflare worker network:

Headers from normal WebSocket:

host: SUBDOMAIN.EXAMPLE.COM
connection: Upgrade
upgrade: websocket
accept-encoding: gzip
x-forwarded-for: ***.***.***.***
cf-ray: **********************
x-forwarded-proto: http
cf-visitor: {"scheme":"http"}
sec-websocket-key: uwajGv+1yR0SvcpZ/N0NbA==
sec-websocket-version: 13
cf-ew-via: 15
cdn-loop: cloudflare; subreqs=1
user-agent: Go-http-client/1.1
sec-websocket-protocol: APc90JU_1UqFyFNFXvJiZwgAAQG7Ag53d3cuZ29vZ2xlLmNvbRYDAQD7AQAA9wMD2XH3EBgloMBU6ue7qIAkeZerrsfWhJ9UeI4d12bGK_ogcVUsQLNXj0ARDCW9XGhCUkN0f-wDqDHTP2fFkwIUxeIAHMypzKjAK8AvwCzAMMAJwBPACsAUwBITAxMBEwIBAACSAAAAEwARAAAOd3d3Lmdvb2dsZS5jb20ABQAFAQAAAAAACgAKAAgAHQAXABgAGQALAAIBAAANABoAGAgEBAMIBwgFCAYEAQUBBgEFAwYDAgECA_8BAAEAABcAAAASAAAAKwAFBAMEAwMAMwAmACQAHQAgOYIYiWVsQHz2iFjlsoCIlu2K0fTimZd8jdRDOLdJljk
cf-connecting-ip: ***.***.***.***
cf-worker: SUBDOMAIN.workers.dev

Headers from httpUpgrade:

host: SUBDOMAIN.EXAMPLE.COM
connection: Upgrade
upgrade: websocket
accept-encoding: gzip
x-forwarded-for: ***.***.***.***
cf-ray: **********************
x-forwarded-proto: http
cf-visitor: {"scheme":"http"}
sec-websocket-key: 9t/YgEV771Cb8IETELn2Ww==
sec-websocket-version: 13
cf-ew-via: 15
cdn-loop: cloudflare; subreqs=1
user-agent: Go-http-client/1.1
cf-connecting-ip: ***.***.***.***
cf-worker: SUBDOMAIN.workers.dev

PS: my connection scheme is like this:

CLient(xray v1.8.10) ---(Vless httpUpgrade (WITH TLS))----> CF-Worker ----(reroute vless through fetch() (NO TLS))----> nginx ---> xray v1.8.10

from xray-core.

us254 avatar us254 commented on May 26, 2024

the issue lies in the communication between the Cloudflare Worker and your server.
example of how you can modify the headers in your Cloudflare Worker:

 addEventListener('fetch', event => {
  event.respondWith(handleRequest(event.request));
});

async function handleRequest(request) {
  const url = new URL(request.url);
  const path = url.pathname;
  const targetUrl = 'https://your-server.com' + path;

  const newRequest = new Request(targetUrl, {
    method: request.method,
    headers: request.headers,
    body: request.body,
    redirect: 'manual',
  });

  newRequest.headers.set('Upgrade', 'websocket');
  newRequest.headers.set('Connection', 'Upgrade');

  const response = await fetch(newRequest);
  return response;
}

from xray-core.

RPRX avatar RPRX commented on May 26, 2024

Cloudflare worker-relay

如果 worker 的代码是解析并重新封装成 WebSocket,则无法支持 HTTPUpgrade

from xray-core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.