I'm trying to combine an express js app with nginx. The express app runs on port 3001 or 8000 and then with nginx I'd like to listen to port 443 and forward the requests to that app:
/etc/nginx/sites-available/example.com has this content:
server {
listen 443 ssl;
server_name example.com;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log debug;
ssl_certificate x.crt;
ssl_certificate_key path/ca.key;
location / {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_pass "http://127.0.0.1:3001";
}
}
but then when I start my expressjs app with forever I get these errors:
Port 3001 requires elevated privileges
error: Forever detected script exited with code: 1
error: Script restart attempt #9
Port 3001 requires elevated privileges
error: Forever detected script exited with code: 1
error: Script restart attempt #10
Port 3001 requires elevated privileges
error: Forever detected script exited with code: 1
error: Script restart attempt #11
Whatever port I try it says it requires elevated privileges. I just want my app to run on https without requiring root privileges. If I start it with sudo and without nginx it works, but I'm trying to avoid that.
Thanks