Skip to content

DeployByNginx

adwpc edited this page May 31, 2020 · 1 revision

Deplay by nginx

1 build app

download

git clone https://github.com/pion/ion-app-web

install deps

cd ion-app-web
npm i

build web app, you will see a dist dir

npm run build

2 deploy by nginx

copy all files in dist dir to nginx's html dir

set the nginx.conf, like:

http {
    map $http_upgrade $connection_upgrade {
        default upgrade;
        '' close;
    }

    server {
        listen       8080;

        # ssl setting, copy the *.pem to nginx.conf dir
        # you can run './scripts/makeKey.sh' to create them to configs
        ssl on;
        ssl_certificate     /usr/local/etc/nginx/cert.pem;
        ssl_certificate_key /usr/local/etc/nginx/key.pem;

        # ws proxy to biz, biz should listen on 8443 without ssl
        location /ws {
            proxy_pass http://localhost:8443/ws;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }

        # 1 run 'npm run build' in ion-app-web dir
        # 2 then copy dist/* to nginx's html dir
        location / {
            root   html;
            index  index.html index.htm;
        }
    }
}