I have a website running on my main domain added in cPanel listening to the main "80" port and can be opened without adding the port to the URL. for example: "http://mywebsite.com".
Now I want to add another website on a new addon domain. But this website is a Next.js app running on port 3000.
I used SSH to successfully build and start the next.js app.
The next.js app opens perfectly on the newly added addon domain with the port 3000. For example "http://new-website.com:3000"
- If I change the port from 3000 to 80 when starting the next.js app, I can open it without adding the port, but the problem is, that my other domain will now also open the next.js app.
My server Information:
- Virtual instance running on google cloud.
- CentOS 7
- Apache Web server (I can turn off Apache and run NGINX if needed)
- cPanel installed
I can of course just create another virtual instance and add my new website there but I don't want to pay double when my current instance is capable of running multiple websites on different domains.
Everything is working perfectly with my both websites and the only problem is I cannot have my both websites work currently without having to add port number to my next.js app.
How do I open my new next.js app without adding the port in a way that my other static website won't be affected and show it's content like before?
Tried:
- I used NGINX reverse proxy, but the same thing happens.
- Changing next.js port from 3000 to 80
- Exporting the next.js app and uploading it as static using "npx next export" but website not working as expected.