Deployment Of Backend WebSocket console application in window VM

Posted By :Aayush Verma |19th July 2022

Dotnet Console App 

Documentation for Deployment Of Backend WebSocket

 

These all steps are followed on Azure Virtual Machine.

 

  1. Run the Build in the system through CMD

Command - “SocketIOSharp-Example Server.exe” and make sure it is running.

 

  1. Now run this command in  backend of VM with full path in powershell

Run the powershell  by administrative

 

Start-Process "C:\Users\examwork\Desktop\finaal call\new1\exam_works_roshan_darnal\backend\ew_prototype_examwork - Copy\SocketIOSharp-Example Server\bin\Debug\SocketIOSharp-Example Server.exe" -WindowStyle Hidden

 

Now from this command project will run in backend 


 

To check our application is running we need to see port number by the command netstat -aon in power shell

 

 

As we see that port 9001 is running in background


 

  1. Now add inbound rule in windows defender firewall 

 

windows defender firewall > advanced setting > inbound rule 

 

        To allow connection we need to define port and allow the connections


 


 

  1. Now add inbound rule on azure virtual machine 

 

Log in azure portal > go to your virtual machine > networking > add inbound rule

 



 

  1. Now stop the internet information service (ISS) manager

 

Go to connection on left side on iss console, click on sites and stop iss

 

and check the status

 

 

 


 

  1. Install nginx on windows

 

http://nginx.org/en/docs/windows.html


 

Path  -  C:\Users\examwork\Downloads\nginx-1.22.0\nginx-1.22.0\conf

 

now change the nginx.config file with this code as per requirements

 

Nginx Configuration Is Here 

******************************************************************************************

 

worker_processes  1;

 

events {

    worker_connections  1024;

}

http {

    include       mime.types;

    default_type  application/octet-stream;

    map $http_upgrade $connection_upgrade {

      default upgrade;

      '' close;

   }

    sendfile        on;

    keepalive_timeout  65;

    server {

        listen       80;

        server_name  examwork.workshopcloud.shop;

        location / {

            proxy_pass   http://127.0.0.1:9001;

}

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        }

    }

 

  upstream websocket {

      server 20.219.124.44:9001;

   }

    server {

        listen       443 ssl;

        server_name  examwork.workshopcloud.shop;

        ssl_certificate      C:\Certbot\live\examwork.workshopcloud.shop\fullchain.pem;

        ssl_certificate_key  C:\Certbot\live\examwork.workshopcloud.shop\privkey.pem;

        ssl_session_cache    shared:SSL:1m;

        ssl_session_timeout  5m;

        ssl_ciphers  HIGH:!aNULL:!MD5;

        ssl_prefer_server_ciphers  on;

        location / {

          proxy_pass   http://websocket;

  proxy_http_version 1.1;

          proxy_set_header Upgrade $http_upgrade;

          proxy_set_header Connection $connection_upgrade;

}

    }

}

 

These changes are for web socket securing with ssl 

 

  A. Server name - examwork.workshopcloud.shop

      B.  Proxy Pass - 9001

      C. Ssl - Certbot Application   Download For Windows

https://certbot.eff.org/instructions?ws=other&os=windows#:~:text=Install%20Certbot.,%2C%20that%20can%20be%20customized

 

       

 ssl_certificate      C:\Certbot\live\examwork.workshopcloud.shop\fullchain.pem;

  Ssl_certificate_key   C:\Certbot\live\examwork.workshopcloud.shop\privkey.pem;

               

      D. apply proxy_pass to web socket 

 

 Some Nginx Imp Commands

./nginx -t 

./nginx -s reload

./nginx stop






 

7.  Restart nginx with powershell

      Run the powershell with administrative 

These are the commands for nginx


 

  nginx -s start          to start 

 

nginx -s stop

fast shutdown

nginx -s quit

graceful shutdown

nginx -s reload

 

nginx -t

modifying configuration, launching new worker processes with a new configuration, and graceful shutdown of old worker processes.

 

To check right configuration in nginx file

nginx -s reopen

re-opening log files



 

wss://examwork.workshopcloud.shop/

 


About Author

Aayush Verma

Aayush Verma is working as a DevOps Engineer having knowledge of AWS services, Linux and Github. He is a quick learner and a Self-motivated Person.

Request For Proposal

[contact-form-7 404 "Not Found"]

Ready to innovate ? Let's get in touch

Chat With Us