Vous devrez configurer un proxy dans NGINX. Ce que vous devez faire, c'est exécuter normalement votre application avec npm run dev, npm start ou une autre méthode de votre choix.
Puis rediriger avec l'emplacement avec proxy_pass. Si vous utilisez 0.0.0.0 dans votre application, vous pouvez accéder à partir de n'importe quelle adresse.
Voyez si mon script pourrait vous être utile.
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
# log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
# access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name localhost mydomain.com;
# Discourage deep links by using a permanent redirect to home page of HTTPS site
return 301 https://$host;
# Alternatively, redirect all HTTP links to the matching HTTPS page
# return 301 https://$host$request_uri;
# API 1
location /api1 {
proxy_pass http://0.0.0.0:8001;
}
# APP 1
location /app1 {
proxy_pass http://0.0.0.0:3001;
}
# APP 2
location /app2 {
proxy_pass http://0.0.0.0:3002;
}
# API 2
location /api2 {
proxy_pass http://0.0.0.0:8002;
}
}
# HTTPS server
server {
listen 443 ssl;
listen 443 ssl default;
server_name localhost, mydomain.com;
gzip on;
ssl_certificate /etc/letsencrypt/live/mydomain/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/mydomain/privkey.pem; # managed by Certbot
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
# config to enable HSTS(HTTP Strict Transport Security)
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
# API 1
location /api1 {
proxy_pass http://0.0.0.0:8001;
}
# APP 1
location /app1 {
proxy_pass http://0.0.0.0:3001;
}
# APP 2
location /app2 {
proxy_pass http://0.0.0.0:3002;
}
# API 2
location /api2 {
proxy_pass http://0.0.0.0:8002;
}
}
include servers/*;
}