1 Star 1 Fork 0

tanpenggood-best-practices / deploying-multiple-web-applications

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Deploying multiple web applications

Deploying multiple web applications with front and back separation under a domain name.

nginx

  • nginx 1.20.2

  • html

    html
    ├─app1
    │  ├─assets
    │  ├─index.html
    │  └─vite.svg
    ├─app2
    │  ├─assets
    │  ├─index.html
    │  └─vite.svg
    ├─50x.html
    └─index.html

nginx.conf

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;
		}
	}

}
MIT License Copyright (c) 2023 tanpenggood Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

Deploying multiple web applications with front and back separation under a domain name. 展开 收起
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/tanpenggood-best-practices/deploying-multiple-web-applications.git
git@gitee.com:tanpenggood-best-practices/deploying-multiple-web-applications.git
tanpenggood-best-practices
deploying-multiple-web-applications
deploying-multiple-web-applications
main

搜索帮助