简体   繁体   中英

How to run express app on port 80 without sudo access

I am using the express framework for nodejs on a Dreamhost VPS and I want to run my server on port 80 but all of the answers I've seen require sudo/root access but on a Dreamhost VPS I am not given this permission. I can't edit any of the Apache files. The only thing I am able to do is create a .htaccess file. How can I achieve this?

You can try to run Node on a different port (greater than 1024, since those of 1023 or lower require root) and just proxy the requests through Apache by adding something like this to your .htaccess file:

RewriteEngine On
RewriteRule ^/(.*)$ http://127.0.0.1:8080/$1 [P,L]

(In this example Node would be running on port 8080).

For anyone who comes across this and has Dreamhost, the solution I came up with was creating a proxy. In the Dreamhost panel there is an option to create a proxy for a domain that you can then direct to go to any port for that domain and I simply made the proxy go to port 3000 and then my node server ran on port 3000 .

@Frxstrem's answer also works but it failed to work when I shared a link and is kind of a hacky solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM