I know it has been asked several times but I can't find any way to solve it.
Recently I've setup an Ubuntu server serving two nodejs app.
Both apps resides on the same domain mydomain.com
but on different ports.
One app is a keystonejs app
the second is a nextjs app
I'm trying to use Nginx to reverse proxy both application. I've been trough lot of tutorials but never find the right answer.
What I would like to achieve is to use nginx to reverse proxy in the following way:
(nextjs) example.com --> localhost:3001
(keystone) example.com/admin --> localhost 3000
The nextjs app works well while the keystonejs not. It returns a 404 page. My understanding is that when I add the location /admin
it changes the path and the app is not able to load static files but I might be wrong.
here is my Nginx conf file.
server {
listen 8080;
listen [::]:8080;
server_name example.com;
return 301 https://example.com$request_uri;
}
server {
listen 443;
listen [::]:443 ssl;
ssl on;
ssl_certificate /mypath/example.com/fullchain.pem;
ssl_certificate_key /mypath/example.com/privkey.pem;
include /mypath/options-ssl-nginx.conf;
ssl_dhparam /mypath/ssl-dhparams.pem;
server_name example.com;
location / {
proxy_pass http://localhost:3001;
}
location /admin {
proxy_pass http://localhost:3000/;
}
}
both application runs inside a dedicated folder so the structure is
└── my-app
├── backend
│ ├── auth.ts
│ ├── keystone.ts
│ ├── package.json
│ ├── package-lock.json
│ ├── README.md
│ ├── Schema
│ │ ├── Blog
│ │ │ ├── linkSchema.ts
│ │ │ ├── postSchema.ts
│ │ │ └── tagSchema.ts
│ │ └── userSchema.ts
│ ├── schema.graphql
│ ├── schema.prisma
│ ├── schema.ts
│ └── tsconfig.json
└── client
├── next.config.js
├── package.json
├── package-lock.json
├── pages
│ ├── api
│ │ └── hello.js
│ ├── _app.js
│ └── index.js
├── public
│ ├── favicon.ico
│ └── vercel.svg
├── README.md
└── styles
├── globals.css
└── Home.module.css
Is there any possibility I should run both nodejs apps in this way? Thanks in advance for any help