Forked from gokman/multiple angular app configuration for nginx
Created
December 17, 2020 03:10
-
-
Save KhoiNguyenICT/373ad7d619fc872ed1e2b881a7c33131 to your computer and use it in GitHub Desktop.
Revisions
-
gokman created this gist
Dec 30, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ 1. build app1 project with prod flag ng build --prod 2. copy files under dist folder to the server scp -r dist/app1/* {username}@{ip address of server}:/var/www/app1/ 3. set base href of application (app1 works on /) <base href="/"> 4. build app2 project with prod flag ng build --prod 5. copy files under dist folder to the server scp -r dist/app2/* {username}@{ip address of server}:/var/www/app2/ 6. set base href of application (app2 works on /app2/) <base href="/app2/"> 7. make nginx configuration in sites-available/my_app file server { listen 8080; server_name {ip address of server}; location / { alias /var/www/app1/; try_files $uri /index.html; } location /app2/ { alias /var/www/app2/; try_files $uri /app2/index.html; } } 8. create symbolic link of above configuration ln -s sites-available/my_app sites-enabled/ 9. restart nginx systemctl restart nginx 10. go app1 http://{server address}/ 11. go app2 http://{server address}/app2/