How to start server on HTTPS?
Unanswered
Western Kingbird posted this in #help-forum
Western KingbirdOP
On my managed webhost, I am running
HTTPS=true npm run start but the server is starting on http://localhost:3000. Anyone know how to start this on HTTPS?10 Replies
@Western Kingbird On my managed webhost, I am running `HTTPS=true npm run start` but the server is starting on http://localhost:3000. Anyone know how to start this on HTTPS?
you can use a third party like
ngrok that gives you a public accessable https url that points to your localhost. It's free 🙂Western KingbirdOP
Thanks @B33fb0n3 , do you have any pointers on how to set this up? Also what is the best way to keep the nextJS app running? Should I use
npm forever ?@Western Kingbird Thanks <@301376057326567425> , do you have any pointers on how to set this up? Also what is the best way to keep the nextJS app running? Should I use `npm forever` ?
you can directly install ngrok on your local machine and start the https server via
ngrok http 3000. Then inside your terminal you see the public accessable url. Also what is the best way to keep the nextJS app runningIf you are on your local machine, you can use
next dev or next start (with next build before next start) and then just keep your terminal open. The same works for an vpsWestern KingbirdOP
On a production server where I need 24/7 uptime, I won't be able to keep the terminal up..
@Western Kingbird On a production server where I need 24/7 uptime, I won't be able to keep the terminal up..
that's why you normally buy an external server (a vps in this case) that runs 24/7 and executed the
start command onceWestern KingbirdOP
Yep, I have an external server and I have the code on there. I just can't figure out how to run it on HTTPS and how to keep the server running on port 3000 forever
@Western Kingbird Yep, I have an external server and I have the code on there. I just can't figure out how to run it on HTTPS and how to keep the server running on port 3000 forever
you server should be available via an ip address (vercel for example is available at
76.76.21.21). So go in your DNS configuration and add your record to it, that redirects the user from example.com to your ip (cname, so the user dont see the ip). The user then can go to http://example.com and will access your server, on which nextjs is running, so the end customer will reach your page. Now you add an SSL certificate to it and then your page is reachable via https://example.com 👍Btw: even vercel is using a third party to make domains available (cloudflare is also in the background=:
@B33fb0n3 Btw: even vercel is using a third party to make domains available (cloudflare is also in the background=:
Western KingbirdOP
What I ended up doing is keep Nodejs as HTTP but updated my Apache reverse proxy for HTTP and HTTPS to point to this same http://localhost:3000. However, I cant figure out how to redirect from HTTP to HTTPS...Any ideas on how to do this?
@Western Kingbird What I ended up doing is keep Nodejs as HTTP but updated my Apache reverse proxy for HTTP and HTTPS to point to this same http://localhost:3000. However, I cant figure out how to redirect from HTTP to HTTPS...Any ideas on how to do this?
To make an public accessable nextjs vps server I only have this idea: https://nextjs-forum.com/post/1260989908961726525#message-1261007526204276806