Nginx Ubuntu is an open source web server with powerful load balancing, reverse proxy and caching features. It was originally developed to address scaling and concurrency failures on existing servers. The asynchronous event-based architecture has made it the most popular and efficient.
Two installation versions
Two open source versions of Nginx Ubuntu are usually chosen - mainstream and stable. The major version represents a small part of the complete package. The status "Development and Trial" does not mean that the main one is vulnerable, on the contrary, it is quite stable. Its advantages: you can always try out the best features and the latest features beforehand. Disadvantage - more chance of getting errors compared to stable.
The latest (full version of Nginx Ubuntu) has been analyzed for features and security through a series of tests and has a very high score. As a result, the user receives a stable and reliable web server that is suitable for use as a servere-commerce.
Nginx installation type
Beginners need to correctly apply the installation parameters to deploy the server.
There are several options for installing Nginx Ubuntu:
- From the finished Debian/Ubuntu package.
- From the finished Nginx repository package.
- From source code.
Installation from prepackaged (Debian/Ubuntu) both with kernel and default module is very easy along with automatic upgrade process. The process is carried out by a program consisting of a stable version and several module options.
Installing Nginx Ubuntu from the repository package is as easy as installing from the default operating system. You can choose to use the stable version or the main one. In addition, you can more flexibly choose the dynamic module that you plan to use. The latter is different from a static module, but some of them can be made dynamic. For Nginx, the process of updating the kernel is quite complicated, so it must be done manually.
Pre-assembled package
If you need more flexibility, installing Nginx from source is the right choice. All modules are used as needed, you can change the main code. Running Nginx install Ubuntu from a prepackaged package:

To set this scheme as default, check Ubuntu or Debian Web to see what modules are built into Full. Next, install the software from the pre-built Repository package.

After that, the following signing key is added to ensure that the repository and packages are listed in the manager keychain (apt).
Installation algorithm:
- Next, add the default Nginx repository from the Ubuntu or Debian package.
- To do this, define the repository in the package file sources.list.
- First open the sources.list file in the nano console as a file editor.
- After opening the file, add the repository to the bottom line with a common template.
- Save changes by pressing Ctrl + x → Y → Enter.
- After that, you can install Nginx in the usual way.
The stable version of Nginx Ubuntu server will be installed on the system.
Where:
- {Linux OS} - Ubuntu or Debian;
- {codename} - OS name.
The code name can be seen in the following table.

Installation code.

Configuring NGINX Ubuntu 18.04
Currently the best way to install the 18.04 model is to use the version included in the Ubuntu repositories.
NGINX configuration files are stored in /etc/nginx/conf.d/. Typically, you will need a separate file in this directory for each domain or subdomain.
Algorithm for installing NGINX on Ubuntu:
- Copy the default file.
- Replace example.com with the site's domain name or public IP.
- Disable the default file by adding.disabled to his name.
- Open the file in the editor.
- Replace the domain name or site IP in the directive.
- For ready-made content, such as WordPress installations or static files, replace the path in the root directive with the path to the site content.

NGINX Testing:
- Check configuration for errors.
- Reload version.
- Go to the Linode IP in the browser and the NGINX page will appear.
Adding a new site to the server
LEMP stack software demonstrates a group that can be used to process dynamic pages and applications. Internal data is stored in MySQL and dynamic processes are handled by PHP Ubuntu Nginx.
Requirements:
- SSH clients like Bitvise or Putty with instructions on how to use them.
- Basic knowledge of common Unix commands for SSH to server.
- Server or VPS with 256MB minimum RAM (OpenVZ). Recommended to use 512 MB if using KVM or Xen.
- Ubuntu 16.04 between 32 or 64 bits.
Prerequisite:
- Provides the Ubuntu server.
- Installs full LAMP (Ubuntu Nginx Apache, MySQL, Perl / PHP / Python) on Ubuntu server.
Creating a web directory
Web directories are lists or folders on a server where all files are stored or hosted. It is logged in using Terminal, Putty and Bitvise.
Next you need a directory. Below this command creates twodirectories for two sites, for example, if you need to add only one site, they simply specify it once, instead of domain1.tld and domain2.tld, they specify the desired domain. Next, set the owner of the directory to www-data and recursively change the permissions on the directory. Place the next one, then create a test index.html file, save and exit the editor by pressing Control+O, then Cotrol+X.

Creating a block service
The Nginx server block file is stored internally, then put this configuration there and replace "xxxx" with your own IPv4 or IPv6 address. Save and exit the editor by pressing Control+O then Control+X. After that, perform similar actions for another site.

Next, you can activate each server block. For security purposes, edit nginx.conf and activate the option: "Name hash size", remove the comment symbol (). Press Control+O to save and Control+X to exit the editor. Now test the configuration and confirm Ok.
Finally, do a reload or restart to restart the service. Then, configure the DNS domain information or edit the local host file on the computer to test the package. Launch a web browser and try to access the VPS through the domain name.
HTTP Server Hosting

HTTP server Nginx (Engine-X) is the most popular of the analogues used on the Internet. It is lightweight, stable, ready to go, whichcan be used by anyone to create powerful and dynamic websites. It can also serve as a proxy server, making it a great choice for securing busy and popular websites.
Install Nginx HTTP server:
- Install the server. Packages can be obtained from the Ubuntu software repository, all you have to do is run apt.
- After the server is installed, configure the firewall to allow HTTP traffic. The Ubuntu firewall is not enabled by default. In some cases, it turns on automatically for security reasons.
- If the firewall is enabled, the given one-liners should allow HTTP traffic on both port 80 and port 443. If you check the firewall status, you can see that HTTP Full is allowed from anywhere, including v6 traffic.
- Open access to the default Nginx website page, or go to the IP of the server or host.
- Additional folders will be created when Nginx HTTP server is installed. They contain configuration files, settings and other directories mentioned above, are the most used on the server.
Using a reverse proxy

A reverse proxy is a server that sits between internal applications and external clients, redirecting client requests. While many common applications such as Node.js can run as servers on their own, NGINX has a number of advanced load balancing, security, and acceleration features,these functions are not available in most specialized programs. Using NGINX as a reverse proxy allows you to add these features to any application.
This uses plain Node.js to demonstrate how to set up NGINX as a reverse proxy.
Set proxy:
- These steps install Mainline on Ubuntu from the official NGINX Inc. repository. For other distributions, please refer to the admin guide for setup information for production environments.
- Open /etc/apt/sources.list with a text editor and add the following line at the bottom.
- Replace codename in this example with the codename of the installed version. For example, Ubuntu Nginx php fpm named Bionic Beaver would be bionic.
- Import the repository package signing key and add it to apt.
- Make sure the server is running and will be enabled automatically on reboot.
Sample application

Use curl to download the setup script provided by NodeSource. Replace the Node version in the curl command with the one you want to place.
Run script:
- The apt-get update script will run automatically so you can install Node.js right away.
- The Node Package Manager (NPM) will be unpacked along with Node.js.
- Create an application directory.
- Initialize the Node.js application in the directory.
- Accept all defaults when prompted.
- Install Express.js: npm install --save express.
- Use a text editor to create and add the following content: app.js.
- Start the application.
- Use curl in a separate terminal window to make sure the software works.
Configuring Node.js
At this point, Node.js can be configured to serve as a sample application on Linode's public IP address, allowing it to be exposed to the Internet. Instead, the section does a php installation of Ubuntu Nginx to forward all requests from the public IP to the server listening on localhost.
Basic configuration for NGINX with reverse proxy: create a file, in this example replace example.com, software domain or public IP address.

The proxy_pass directive is a reverse proxy configuration. It specifies that all requests that match the location block, in this case the root path, should be redirected to port 3000 on localhost running Node.js.
Setting procedure:
- Disable or remove the default page Welcome to NGINX:sudo mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.disabled.
- Check configuration: sudo nginx -t.
- If no errors are reported, reload a new one:sudo nginx -s reload.
- Browser navigates to Linode public IP address, Hello World!
Additional parameters: permalink

For a simple application, the proxy_pass directive is sufficient. However, more complex ones may require additional parameters. For example, Node.js is often used for cases that require a lot of real-time interaction. To adjust, disable the buffering feature of Nginx Ubuntu ssl. You can change or add headers that are sent along with proxy requests to proxy_set_header. This configuration uses the built-in $remote_addr variable to send the IP address of the original client to the proxy host.
One of the benefits of a reverse proxy is the ease of setting up HTTPS with a TLS certificate. Certbot is a tool to quickly get free certificates from Let's Encrypt. You can use Certbot in Ubuntu 16.04, the official site contains detailed instructions for installing and using the main distributions. After receiving the certificates through Certbot, it will automatically update the files to use the new certificate.
Certbot will request information about the site. The answers will be saved as part of the certificate.

Certbot will also ask if you want to automatically redirect HTTP traffic to HTTPS. It is recommended to select this option. After the tool finishes running, Certbot will store the generated keys and issued certificates in the /etc/letsencrypt/live/$domain directory, where $domain is the domain name entered during the Certbot certificate generation step.
Certbot recommends specifying the web server configuration in the default certificate directory or creatingsymbolic links. Keys and certificates should not be moved to another directory. Finally, Certbot will update the server to use the new certificate and also redirect HTTP traffic to HTTPS if this option is selected.
If a firewall is configured on Linode, you can add a firewall rule to allow incoming and outgoing connections to the HTTPS service. On Ubuntu, UFW is a widely used and simple tool for managing firewall rules.

One of the requirements to implement an application or website is to have a web or HTTP server on the server side that does the processing. The latter establishes bidirectional or unidirectional connections with the client and generates a response to requests made. Therefore, it is an integral part of the web infrastructure.
Statistically, Nginx is a growing web server that is attracting more and more webmasters around the world. Compared to Apache and other web servers, Nginx is vastly superior in terms of concurrent session processing speed, response time, and resource usage. This is due to the architecture and smart handling of connections. Another benefit offered by Nginx is its asynchronous architecture, which improves the handling of concurrent connections.