Origin rules not working

I have some self-hosted services(NAS, openwrt, Home assistant etc.) in my home , here’s what I want:

  • https://nas.mydomain.com point to port 5001 of my IP address(something like this: https://mydomain.com:5001)
  • https://ha.mydomain.com point to port 8123 of my IP address

I’ve done these ports forwarding on my router and was successfully tested

Since I don’t want to access these services by specify the “ports” that following by the domain name,
so I created some “Origin Rules”, which are pretty simple, just like "

if http.host eq nas.mydomain.com
then
rewrite to port 5001

But, these port rewriting does not work anyway, when I try to http(s)://nas.mydomain.com and I got 502 http error

Does anyone have any ideas what I missed?

Thanks!