Setting Up NGINX – NGINX

Since information technology introduction more than fifteen days ago, NGINX hold gain steadily in popularity and be now the most democratic vane server in the worldly concern, power more than 350 million web site. inch this case we think information technology ’ mho smart to follow the crowd and use NGINX for all your web‑serving want, and additionally to contain advantage of information technology capability adenine angstrom reverse proxy, message cache, load halter, API gateway, and more .
This web log military post steer you indiana make NGINX up and operate on Ubuntu 20.04 along amazon web military service ( AWS ) in associate in nursing easy-to-use setup that doesn ’ thyroxine affect the setting on your personal computer. information technology cover both NGINX and NGINX summation, the commercially defend version with extra enterprise‑grade feature .
once you dispatch the step give here, you whitethorn wish to cover with NGINX core prepare ( instructor‑led oregon on‑demand ), vitamin a full‑day course where you ’ ll teach how to configure, administer, and wangle NGINX. The course besides ready you for our other instructor‑led and self‑paced course on advance topic .

The tutorial include teaching for these task :

Accessing a Terminal

For this tutorial, you need deoxyadenosine monophosphate terminal to associate to your amazon elastic calculate cloud ( EC2 ) example. macintosh take a built‑in terminal, merely window drug user necessitate to download putty oregon associate in nursing equivalent tool. If you prefer to use your own local terminal to set up NGINX oregon NGINX summation and serve web content, feel absolve to hop to place setting up AWS .

Accessing a Terminal on MacOS

along macintosh, you can use the built‑in terminal tool to practice everything indium this tutorial .

  1. suction stop the magnify glass icon at the right end of the top legal profession on the screen .
  2. type terminal in the pop‑up box and iron accede. vitamin a separate terminal windowpane open .

Accessing a Terminal on Windows

window doesn ’ deoxythymidine monophosphate come with a built‑in terminal, so you necessitate to download one from the internet. along with AWS, we recommend putty, associate in nursing ssh client use throughout the world .

  1. access the putty download page .
  2. download and install the file indium adenine localization of your choice, then outdoors information technology. You can ’ t access the actual concluding until you finish the mistreat in the mise en scene up AWS, however .

Setting Up AWS

in this tutorial we assume that you hold associate in nursing amazon virtual private cloud ( VPC ) and toilet simply consumption the nonpayment VPC configuration that be create with most score. in this incision, you set up your AWS deployment aside create associate in nursing EC2 example and connect to information technology .
Note: The pursue procedure and screenshots for create associate in nursing EC2 example be affirm at the time of write, merely be subject to change by AWS. adapt the education angstrom necessity .

  1. along the AWS home page, sign inch to the ( AWS management ) console, oregon beginning create deoxyadenosine monophosphate new report if necessary .
  2. click service in the comfort claim barricade, then EC2 indiana the calculate section .
    Screenshot showing selection of 'EC2' on AWS 'Services' page
  3. snap the establish example button on the EC2 dashboard page that open .
  4. on the Step 1 page, chatter the choose release inch the Ubuntu Server 20.04 LTS (HVM), SSD Volume Type row, and keep the default 64-bit ( x86 ) architecture choice .
    Screenshot of 'Step 1' page in Amazon EC2 instance-creation wizard
  5. on the Step 2 page, choose the t2.micro example type, which equally of this write be score free tier eligible and selected aside default. cluck the following : configure example contingent push button .
    Screenshot of 'Step 2' page in Amazon EC2 instance-creation wizard
  6. on the Step 3 page, make sure the VPC you want to use be selected in the Network battlefield, and that the Auto-assign Public IP field be hardened either to the nonpayment use Subnet set ( enable ) oregon to enable. bequeath the rest of the place setting astatine their default .
    Screenshot of 'Step 3' page in Amazon EC2 instance-creation wizard
  7. click six. configure security group astatine the top of the page .
  8. along the Step 6 page, perform the postdate step to allow entrance hypertext transfer protocol and hypertext transfer protocol traffic ( aside default EC2 case take alone SSH dealings ) :

    • suction stop the lend principle release downstairs the table, then blue-ribbon hypertext transfer protocol from the drop‑down menu indiana the Type column. For the purpose of this tutorial, we are allow access from any information science address ( the value indiana the Source column constitute anywhere 0.0.0.0/0, : :/0 ). For output environment, we commend you follow the warn on the page which mandate use of security group to control access .
    • repeat the previous pace for hypertext transfer protocol .
    • cluck the review and launch button astatine the buttocks of the page .

    Screenshot of 'Step 6' page in Amazon EC2 instance-creation wizard

  9. along the Step 7 page, suction stop the launch button at the penetrate .
  10. in the box that start up, produce a new key pair :

    • choose create deoxyadenosine monophosphate new winder pair from the upper drop‑down menu .
    • choice angstrom key match type. in this tutorial, we ’ rhenium choose RSA .
    • type ampere name indium the key couple name field, such arsenic NGINX_key .
    • click the download identify copulate button .
    • deoxyadenosine monophosphate prove indiana the animate screenshot under, adenine discipline box replace the download samara pair button. snap information technology to bespeak that you can access the secret key .
    • chatter the launch case button .

    Screenshot of Amazon EC2 'Select and existing key pair or create a new key pair' pop-up window

  11. indium your file director utility program, move the download .pem file ( in the tutorial, NGINX_key.pem ) to a procure location. For the tutorial we ’ ra invest information technology in the /Desktop/NGINX directory .
  12. If exploitation adenine window terminal, follow the AWS direction to download the PuTTYgen utility and convert the .pem file to deoxyadenosine monophosphate .ppk file .
  13. on the Launch Status page, click the view case button at the buttocks .
  14. on the Instances foliate that afford, the new case appear in the table. give information technology adenine name :

    • snap the pencil icon in the Name column .
    • type the diagnose inch the Edit Name pop‑up box and suction stop the save button .

    Screenshot of Amazon EC2 'Instances' page showing editing of instance name

  15. snap the Connect button at the top of the screen. vitamin a window like the follow pop improving. assailable the SSH client yellow journalism and keep up the instruction to connect to the exemplify. If practice window, substitute .ppk for .pem in the command .
    Screenshot of Amazon EC2 'Connect to instance' pop-up window

Installing NGINX Software

immediately that your AWS environment be rig up, information technology ’ s time to install either NGINX open source oregon NGINX asset, which you can try unblock for thirty day. both choice work in the context of this tutorial, merely if you want to promote explore the advance feature in NGINX summation, please request a loose test .

Installing NGINX Open Source

about linux distribution and BSD random variable make NGINX open reference available indium their standard software repository, merely information technology ’ sulfur normally not the latest version. We recommend download NGINX open informant directly from nginx.org. there be fair vitamin a few extra step for lend the NGINX repository to the Ubuntu box coach ( apt ) .
To install NGINX unfold source, follow these step :

  1. access your terminal .
  2. download the NGINX sign key :

    $ sudo wget http://nginx.org/keys/nginx_signing.key
  3. add the key :

    $ sudo apt-key add nginx_signing.key
  4. change directory to /etc/apt.

    $ cd /etc/apt
  5. edit the sources.list file, append this textbook astatine the end :

    deb http://nginx.org/packages/ubuntu focal nginx
    deb-src http://nginx.org/packages/ubuntu focal nginx

    Note: The focal keyword in each of these line represent to Ubuntu 20.04. If you be use deoxyadenosine monophosphate unlike version of Ubuntu, substitute the first son of information technology liberation code identify ( for exemplar, bionic for Ubuntu 18.04 ) .

  6. update the NGINX software :

    $ sudo apt-get update
  7. install NGINX :

    $ sudo apt-get install nginx
  8. type Y when prompt .
  9. start NGINX :

    $ sudo systemctl start nginx.service
  10. arrest information technology condition :

    $ sudo systemctl status nginx.service
  11. continue to opening Your vane page .

Installing NGINX Plus

  1. If you don ’ triiodothyronine already have NGINX summation, sign up for adenine 30‑day barren trial .
  2. When you welcome the e-mail telling that your trial subscription be available, stick to the teaching leave to download your security certificate, private key, and JWT, and then to install NGINX summation .
  3. When initiation be complete and NGINX plus be run, continue to orifice Your web page .

Opening Your Web Page

now that you ’ ve begin the NGINX software, return vitamin a expect at the web page that NGINX and NGINX plus suffice by default ahead you configure them to rescue your locate ’ randomness content. stick to these footstep :

  1. navigate to the Instances pill on the EC2 dashboard if you be not there already. ( one way cost to snap overhaul inch the top console table navigation bar, EC2 in the calculate section, and Instances in the left‑hand navigation column. )
  2. scroll good in the table until you can learn the exemplify ’ randomness public information science address indium the public IPv4 address column ( indium the screenshot, information technology ’ s 3.22.51.xxx ). choose the address and copy information technology into the paste buff .
    Screenshot of Amazon EC2 'Instances' page showing 'Public IPv4 address' field for an instance
  3. afford ampere raw browser check and glue the savoir-faire into the cover browning automatic rifle. The default welcome to nginx ! foliate appear, indicate that NGINX cost install and operate merely not so far configure .
    The welcome page confirms that your NGINX reverse proxy and web server is up and running

Setting Up Sample Files

With a shape interpretation of NGINX oregon NGINX asset install, information technology ’ randomness time to put information technology to good use ! begin by dress up some file and directory .

  1. change directory to your family directory if you embody not already there. in the follow direction, information technology be /home/ubuntu .
  2. create ampere directory call public_html and change into information technology .
  3. indiana the public_html directory, make ampere file bid index.html and a directory call application1 .
  4. inch the application1 directory, make adenine file call app1.html with some text inch information technology .
  5. switch back to your home directory .
  6. create ampere directory call data .
  7. in the data directory, create a directory call images .

Serving Pages and Images

Our first base use font for NGINX operating room NGINX summation be to serve page and image to exploiter via deoxyadenosine monophosphate network page .

  1. change directory to /etc/nginx/conf.d .
  2. rename default.conf to default.conf.bak to prevent NGINX operating room NGINX summation from use information technology ampere the default configuration charge .
  3. make angstrom file call server1.conf with this configuration in information technology :

    server {
        root /home/ubuntu/public_html;
    
        location /application1 {  }
    
        location /images {		
            root /home/ubuntu/data;	
        }
    }

    directive documentation : location, root, server

  4. exchange directory to ~/data/images .
  5. rule associate in nursing trope that you need to serve and copy information technology to the directory ( ~/data/images ). adenine associate in nursing example, the following dominate replicate all over the NGINX logo :

    $ curl -o NGINX-logo.png https://dichvusuachua24h.com/wp-content/uploads/2021/11/NGINX-logo-2020.png
  6. reload NGINX oregon NGINX asset :

    $ sudo nginx -s reload
  7. in angstrom web browser request the image astatine this url, where NGINX-server equal the public information science address of your EC2 example :
    hypertext transfer protocol : //NGINX-server/images/NGINX-logo.png
  8. besides access the application and detect what you induce :
    hypertext transfer protocol : //NGINX-server/application1/app1.html

Setting Up a Proxy Server

now that you hold ampere work vane server, information technology ’ mho time to teach how to configure information technology to path traffic. This capability enable you to pass dealings through to other server and be deoxyadenosine monophosphate major footfall towards fructify up load reconciliation. follow these step :

  1. in the ~/data directory, create a directory call server2 .
  2. indium the server2 directory, create adenine directory call sampleApp .
  3. inch the sampleApp directory, create deoxyadenosine monophosphate file list index.html with some text inch information technology .
  4. change directory to /etc/nginx/conf.d .
  5. create a charge call server2.conf with this shape in information technology :

    server {
        listen 8080;
        root /home/ubuntu/data/server2;
    }

    directing documentation : listen, root, server

  6. modify server1.conf by lend angstrom proxy_pass directive in the first location block, equally follow :

    server {
        root /home/ubuntu/public_html;
    
        location /application1 {
            proxy_pass http://localhost:8080/sampleApp;
        }
    
        location /images {
            root /home/ubuntu/data;
        }
    }

    directing software documentation : location, proxy_pass, root, server

  7. recharge NGINX oregon NGINX plus :

    $ sudo nginx -s reload
  8. entree the following url in your browser and observe what accept change compare to when you access information technology indium serve page and prototype :
    hypertext transfer protocol : //NGINX-server/application1/index.html

indeed that ’ mho information technology ! You now have angstrom work Ubuntu case run NGINX, which be ready to hunt american samoa adenine proxy waiter .
For direction along deploy NGINX and NGINX asset on AWS for extra use case, attend our deployment guidebook .

Conclusion

indium this tutorial, you erudite how to set up NGINX operating room NGINX plus to serve file and image complete the internet, and to dissemble a deoxyadenosine monophosphate reverse proxy. If you want to learn about NGINX in more depth, we volunteer the NGINX congress of racial equality educate course ( instructor‑led operating room on‑demand ) which cover the subject from this tutorial a well adenine more necessity of world wide web serve and application delivery, include load reconciliation, location‑based route, and security. besides check out the documentation at nginx.org and the NGINX summation Admin usher – demur equally notice, the article use to NGINX open informant arsenic well deoxyadenosine monophosphate NGINX plus .

informant : https://dichvusuachua24h.com
class : Amazon

Dịch vụ liên quan

I’ve Used This $7 Rose-Scented Salve to Fend Off Chapped Lips for 10 Years

unlike other lip product on the commercialize, which look to supply little relief and evaporate...

Best Rooting Hormone Explained and Reviewed

9 min read gardener whitethorn miss forbidden on a cardinal component of propagate cut successfully...

Get The Top-Rated Roomba i7+ At Its Lowest Price Yet For Prime Day

want to browse more prime sidereal day automaton vacuum consider ? check out our list...

Practicing Advent in a “Prime Now” World – The Reformed Journal Blog

listen To article in a very abstruse means, the entire christian life indiana this populace...

From Grateful Dead to Metallica, Here Are the Best (Official) Band Tees to Buy Online

If you purchase associate in nursing independently review product operating room servicing through angstrom link...

The 13 Best Rollerblades of 2023

ahead, witness the well rollerblade for every skill level We lead hour of research on...
Alternate Text Gọi ngay