代码拉取完成,页面将自动刷新
Deploying multiple web applications with front and back separation under a domain name.
nginx 1.20.2
html
html
├─app1
│ ├─assets
│ ├─index.html
│ └─vite.svg
├─app2
│ ├─assets
│ ├─index.html
│ └─vite.svg
├─50x.html
└─index.html
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
# app1 upstream
upstream app1{
server localhost:9001;
}
# app2 upstream
upstream app2{
server localhost:9002;
}
server {
listen 9999;
server_name localhost;
# app1 frontend
location / {
root html/app1;
index index.html index.htm;
# 解决路由模式为history时,刷新页面404的问题
try_files $uri $uri/ /index.html;
}
# app2 frontend
location /ui2 {
alias html/app2;
index index.html index.htm;
# 解决部署在二级目录下且路由模式为history时,刷新页面404或空白的问题
try_files $uri $uri/ /ui2/index.html;
}
# app1 backend
location /app1 {
proxy_pass http://app1;
proxy_redirect default;
}
# app2 backend
location /app2 {
proxy_pass http://app2;
proxy_redirect default;
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。