DEV Community

Chandra Prakash Pal
Chandra Prakash Pal

Posted on

Create virtual host on nginx server(Ubuntu)

The deployment of application on server is a very tedious task. From installation of nginx to creation of virtual host and linking of virtual host from /etc/nginx/sites-available to /etc/nginx/sites-ebabled. Without the enable of virtual host will not work.

Following are steps to create virtual host and make it enabled to work.

  1. create a host file on location /etc/nginx/sites-available/{your_host_file}
    Ex. /etc/nginx/sites-available/demo-app

  2. Next add the following code in host file

server {
location / {
proxy_pass http://localhost:4100;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}

  1. Now enable the host by following commnad

sudo ln -s /etc/nginx/sites-available/demo-app /etc/nginx/sites-enabled/

Top comments (0)