Changing origin server port


#1

Hello,

I’m trying to connect to a service not on a standard port (443, 8443), I thought it would be doable in Workers. I connect to the standard 443 port, intercept the request, change the origin port to whatever I want and then reply. It doesn’t seem to work though.

At the moment I’m trying with this code, but it gives a Compute Error.

  var newURL = new URL(request.url)
  newURL.port = '***'

  return fetch(newURL, request)

I tried also verifying if the ports were open outbound from the Worker and they are. There is no apparent error given, the origin has a valid, albeit not on the exact hostname SSL certificate, which is solved by a SSL Full Page Rule.

Any ideas? A bug in the Worker, in my code or it’s not doable @KentonVarda?


#2

Hi @matteo, We have a change in review now to enable this, most likely landing Wednesday. Keep in mind the url will need to be on your Cloudflare zone (i.e. x.mysite.com) but Gray Clouded (not proxied), we don’t intend on allowing proxying to arbitrary ports on arbitrary hosts yet.


#3

Thanks for the info! Is it a coincidence that you replied at the same time as the Support ticket? :joy:

Though in this case it would be the same exact host. Would that work or I do need an additional entry + hostname change + resolveOverride?

USER <- nas.example.com:443 -> CF <- nas.example.com:8000 -> ORIGIN

FYI: I can already fetch any port of any random page and return it, just not the requested one, preventing the usage as an actual proxy.


#4

I believe it actually works for any host in your zone, whether orange-cloud or gray-cloud.


#6

Sorry, I meant it will work after this week’s update that @zack mentioned. But @zack said it would only work for gray-cloud hosts – I believe that part is incorrect.


#7

Now I understand! Removed the post for the host… You should put out some sort of change log for the dev functions, it would help!

Would you mind telling me when it will be pushed out?