So basically what I want to ask is, I have 2 nextjs app and I want to serve one app in port 4000 like when I type ip-address:4000 it should open myapp1 and another app in ip-address:5000 in an AWS EC2 instance. I have tried creating a custom server and giving the ports in server.js in next app itself but the custom server is very slow and takes away the automatic static optimization feature and the site is very slow.
My /etc/nginx/conf.d/myapp.conf looks like:
server {
listen 80;
listen [::]:80;
server_name ip-address;
root /var/www/html/;
location /myapp/build/ {
proxy_pass http://127.0.0.1:4000
}
}
server {
listen 80;
listen [::]:80;
server_name ip-address;
root /var/www/html/;
location /myapp2/build/ {
proxy_pass http://127.0.0.1:5000
}
}
Also the sites enable looks like:
https://i.stack.imgur.com/Se46V.jpg
Also any reference and guide will be appreciated. Thanks.