On some Linux distros, notably Ubuntu, non-root users cannot bind to ports less than 1024. (See my notes below for evidence.)
There are various ways to address this. See:
More generally though, to answer the question of "how to I get a SSL-secured website running on Elastic Beanstalk". I would say: Don't terminate your TLS/SSL in your application.
In my experience, using an Elastic Load Balancer to terminate your SSL/TLS is an altogether far simpler solution. (If you use Amazon Certificate Manager (ACM) to issue and manage your certs). ACM will automatically update certificate before expiration too!
If you do really want to keep your cert on-instance, then I would recommend you use a "real" web server, like nginx to front your nodejs process. nginx has facilities to install your SSL certs[1] and plugins to automate their issuance and renewal via LetsEncrypt[2]. And quite simply that's what its designed to do.
- I don't know which specific EB platform you're using, but many of them (all of them?) come pre-installed with web server's running by default. (e.g., the docker platform runs
nginx, the python platform runs apache). As such, it is likely you already have an appropriate web server installed on your EB instance.
The following was executed on an Ubuntu docker instance. (The command is just a one-line command to start a python HTTP server at the specified port.) You can see that port 1025 always works. But port 1023 only works as root.
root@24928b62f0bd:/# python3 -m http.server 1025
Serving HTTP on 0.0.0.0 port 1025 (http://0.0.0.0:1025/) ...
^C
Keyboard interrupt received, exiting.
root@24928b62f0bd:/# python3 -m http.server 1023
Serving HTTP on 0.0.0.0 port 444 (http://0.0.0.0:1023/) ...
^C
Keyboard interrupt received, exiting.
root@24928b62f0bd:/# useradd bob
root@24928b62f0bd:/# su bob
$ python3 -m http.server 1025
Serving HTTP on 0.0.0.0 port 1025 (http://0.0.0.0:1025/) ...
^C
Keyboard interrupt received, exiting.
$ python3 -m http.server 1023
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/lib/python3.6/http/server.py", line 1211, in <module>
test(HandlerClass=handler_class, port=args.port, bind=args.bind)
File "/usr/lib/python3.6/http/server.py", line 1185, in test
with ServerClass(server_address, HandlerClass) as httpd:
File "/usr/lib/python3.6/socketserver.py", line 456, in __init__
self.server_bind()
File "/usr/lib/python3.6/http/server.py", line 136, in server_bind
socketserver.TCPServer.server_bind(self)
File "/usr/lib/python3.6/socketserver.py", line 470, in server_bind
self.socket.bind(self.server_address)
PermissionError: [Errno 13] Permission denied
$
[1] http://nginx.org/en/docs/http/configuring_https_servers.html
[2] https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-18-04