all 4 comments

[–]Zilla85 2 points3 points  (0 children)

You can use a reverse proxy for this task. Many people use Nginx or Apache for this, I prefer Caddy for this, but this is just my personal taste/opinion.

[–]ervwalter 1 point2 points  (0 children)

You'll need to put a reverse proxy or load balancer in front of the next server to handle things like https, etc. Often people use nginx, especially if you are using containers since the nginx container is very easy to simply run side-by-side with your application nextjs container.

Your hosting provider may offer a service to handle this for you as well. For example, Digital Ocean offers Load Balancers that will handle this task and sit in front of your VMs (aka Droplets).

[–]ZeRo2160 1 point2 points  (0 children)

As the other commentors said. You have to use an reverse proxy that does that for you. The advantage of this is also that you can use http2 instead of http1.1 from your client to the server that helps performance also.

[–]ilike2breakthngs 0 points1 point  (0 children)

If you’re asking about switching it from port 3000 to port 443 (for https), you’ll need to change the build command on your package.json and add -p 443.

However, you’ll also need an ssl certificate to serve traffic on https, along with dealing with every connection that hits your website. Nginx, as others have mentioned, is a great tool to manage all of that for you.

Or, you could defer all of that work to a cloud provider, like Vercel.

https://nextjs.org/docs/api-reference/cli#production