0

I've successfully created a WS Server using Node.js and wxpress-ws. The problem is that I don't know which port to use to not type it in the request URL. So, instead of using ws://mysite.com::xxxx/, I need to be able to type only ws://mysite.com/

I've tried to listen port 80, 8080, without success.

Bruno Albuquerque
  • 597
  • 1
  • 7
  • 21
  • check out this answer for indirect approach https://superuser.com/questions/111685/how-can-i-specify-ip-and-ports-for-a-hostname-in-the-windows-hosts-file – 1565986223 Apr 12 '19 at 17:12

1 Answers1

1

If your application is listening on port XXXX then you will need to access it via indicating the port in your url ws://myapp.com:XXXX/.

If you want to use ws://myapp.com/, you will need to listen to the port 80, two solutions for you :

  • Launch your application with sudo node myapp.js privileges and make it listen on port 80. I don't recommend this approach since it might introduce some vulnerabilities because the app is running with admin privileges.
  • Set up some reverse proxy like nginx that will listen on port 80 and that will redirect the traffic to your application listening on port XXXX. You can find a lot of tutorials online
HRK44
  • 2,382
  • 2
  • 13
  • 30