Android Data Collection : FORMBOX

Setting Up Nginx in Ubuntu

setupNiginx

Setting Up Nginx in Ubuntu

This post describes how to setup nginx in ubuntu running in local system, AWS, GoolgeCloud or any cloud platform
  • Login into system
  • Update your package
    • sudo apt update
  • Install nginx
    • sudo apt install nginx
  • Start nginx
    • sudo service nginx start
  • Check if nginx running
    • In Browser open http://localhost
    • In terminal run command curl localhost
    • In both cases you will see nginx welcome page.
  • Make nginx route traffic to some server
    • go to dir cd /etc/nginx/sites-available/
    • create file vi myapp
    • add route inside the file
    server {    
           listen 80; 
           server_name www.androidlearner.com androidlearner.com;
               location / 
                   {
                       proxy_pass http://localhost:5000;
                      # proxy_redirect off;
                      # proxy_http_version 1.1;
                     #  proxy_set_header Upgrade $http_upgrade;
                    #   proxy_set_header Connection "upgrade";
                     #  proxy_set_header Host $host;
    
                   }
    
    
    location /backend/
                   {
                       proxy_pass http://localhost:3000/;
                      # proxy_redirect off;
                      # proxy_http_version 1.1;
                      # proxy_set_header Upgrade $http_upgrade;
                      # proxy_set_header Connection "upgrade";
                      # proxy_set_header Host $host;
    
                   }
    
    
    }```
    
  • create link of this file inside /etc/nginx/sites-enabled/
    • sudo ln -s /etc/nginx/sites-available/myapp /etc/nginx/sites-enabled/
  • Reload nginx to reflect the changes
    • sudo service nginx reload
Nginx is setup in the system.
Please ensure your firewall is properly setup

Comments