Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nodamu/5f4b3a49a642fe390405bd2ac1d95efe to your computer and use it in GitHub Desktop.
Save nodamu/5f4b3a49a642fe390405bd2ac1d95efe to your computer and use it in GitHub Desktop.

Revisions

  1. @gokman gokman created this gist Dec 30, 2019.
    50 changes: 50 additions & 0 deletions multiple angular app configuration for nginx
    Original 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/