Tag Archives: Nginx

The Instant Dynamic Caching System Of Sangkrit.net Hosting & Servers

Now every server owner at Sangkrit.net can easily accelerate his websites by caching both static and dynamic content and reducing the load on his servers.

How Dynamic Caching Works?

Dynamic caching works by temporarily storing the dynamically generated content in a cache. When a user requests a particular piece of content, the web server first checks if a cached version of that content is available. If it is, the server serves the cached content, which is faster than generating it from scratch. If not, the server dynamically generates the content, serves it to the user, and caches it for future requests.

How To Enable Dynamic Caching On Your Server?

After you buy any Linux-based VPS or Dedicated Server, you can enable caching for yourself and also your clients by providing a caching button on every hosting account you make on your server. You and your users may use this button to turn on catching, simply follow these steps:

  1. Login to your Sangkrit.net account
  2. Visit your ‘My Products’ page
  3. Click the ‘Servers’ option
  4. Next to ‘Server Actions’ click ‘Launch WHM’
  5. Open ‘Nginx Manager’ from the software section menu on the left
  6. Enable the caching

The page allows you to enable the caching on any or all hosting accounts running on your server You can also enable cache by default for all hosting accounts or click the ‘User Settings’ tab to enable NGINX caching selectively on accounts. It also provides you the option to selectively or collectively delete your server’s cache.

Nginx Cache i.e. “HTTP Caching” Or “Proxy Caching

Nginx cache, often referred to as “HTTP caching” or “proxy caching,” is a powerful feature that allows you to temporarily store and serve web content more efficiently. It is designed to reduce the load on web servers, decrease page load times, and improve the overall performance and user experience.

Every cPanel user account created by you on your VPS or Dedicated Server also gives an option to enable caching over the websites running on the same server but have different hosting accounts.

You can turn on, turn off, or delete the cache on any website simply from the server’s main page on your Sangkrit.net account.

Configuring One Server To Handle HTTP & HTTPS Respectively

On an Nginx server, it is possible for you to configure it to manage both HTTP and HTTPS requests.

You should also know that prior to 0.7.14, it was not possible to enable SSL certificate selectively over individual listening sockets, as we have done here in the following given code:

server {
    listen              80;
    listen              443 ssl;
    server_name         www.yoursite.com;
    ssl_certificate     www.yoursite.com.crt;
    ssl_certificate_key www.yoursite.com.key;
    ...
}

Before SSL could only be enabled over the entire server using an SSL directive, thus it was impossible to put up a single HTTP/HTTPS server. Afterward, the SSL parameter of the listen directive was added to resolve this problem.

The use of the SSL directive in newer versions has been discouraged.

When Multiple HTTPS Servers Listen On A Single IP Address

In SSL protocol conduct, a typical problem occurs when two or more configured HTTPS servers listen on a single IP address.

server {
    listen          443 ssl;
    server_name     www.yoursite.com;
    ssl_certificate www.yoursite.com.crt;
    ...
}

server {
    listen          443 ssl;
    server_name     www.yoursite.org;
    ssl_certificate www.yoursite.org.crt;
    ...
}

As shown above, what exactly happens here is that the client browser starts to receive the default server’s certificate (www.yoursite.com) regardless of the name of the server requested.

This is pushed by SSL protocol conduct. Here, the connection via SSL is made before the browser sends another HTTP request and Nginx does not know the server name requested. Hence, it may only offer the default server’s certificate.

Here’s the solution:

server {
    listen          192.168.1.1:443 ssl;
    server_name     www.yoursite.com;
    ssl_certificate www.yoursite.com.crt;
    ...
}

server {
    listen          192.168.1.2:443 ssl;
    server_name     www.yoursite.org;
    ssl_certificate www.yoursite.org.crt;
    ...
}

Above given is the ancientest and most powerful way used for resolving this issue. Here a separate IP address is assigned for each HTTPS server.

Updating Nginx Server Configuration To Use The SSL You Have Purchased

You need to update the config file on your server to use the SSL certificate you are subscribed to. This can be done by accessing the command line SSH and opening the Nginx config file for the domain you are installing the SSL certificate.

Simply run the following command:

sudo vim /etc/nginx/sites-available/yourwebsite.com

Now update the config file to use the SSL certificate:

server {
        listen 80;
        server_name yourwebsite.com;
        return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;

    server_name yourwebsite.com;
    ssl_certificate     /etc/nginx/ssl/yourwebsite.crt;
    ssl_certificate_key /etc/nginx/ssl/yourwebsite.key;

    root /usr/share/nginx/yourwebsite.com/;
    index index.php  index.html index.htm;

}

The next step is to save the file using this command:

wq!

And then restart your Nginx server with this command:

sudo service nginx restart

That’s it.

Configuring SSL & Intermediate Certificates On Nginx Server

In the previous lesson, you learned about installing and configuring Nginx on your dedicated server. Now this lesson is on installing SSL and other standard certificates.

The first thing you need to do is get an SSL certificate from Sangkrit.net, once you subscribe to it and your certificate request is approved just download it to install those files on your dedicated server.

To download and install your certificate files follow these steps:

  1. Visit your Sangkrit.net product page
  2. Select SSL Certificates
  3. Select Manage next to the certificate you need to download
  4. Select a Server type
  5. Click the Download Zip File option
  6. Your certificate would start downloading now.
  7. Copy the SSL certificate file and the certificate bundle file to the Nginx server
  8. You already have a key file on the server which you got when you generated your certificate request.
  9. Now edit your Nginx configuration to reference these files

Your certificate is installed now. Remember, the actual configuration file you edit depends on your version of Nginx, your OS platform, or the method you are using to install Nginx.

Installing & Configuring Nginx On Your Dedicated Server

Nginx is a web server that is also used as a reverse proxy option. It also balances the load on your dedicated server and acts as a mail proxy as well as an HTTP cache. It is software used for high performance on your server.

This lesson will guide you in installing and configuring Nginx and for that, you are going to need the root privileges. You will also require to set up your CentOS server to use the EPEL Repository which stands for Extra Packages for Enterprise Linux.

To install EPEL simply run this command:

sudo yum install epel-release

You can read more about its configuration steps here. Earlier we installed yum as a package manager but it does not include any new version of Nginx in its default repository so installing EPEL will make sure that Nginx on CentOS remains up to date.

You are ready to install Nginx

Now you are ready to install Nginx on your server, simply run the following command:

sudo yum install nginx

Next, start Nginx:

Nginx doesn’t start on its own, so you will need to run a command for starting Nginx on your server:

sudo /etc/init.d/nginx start

To make sure Nginx is properly installed on your server, just direct your browser to your server’s IP address. If you see the words, “Welcome to Nginx”, it means you have Nginx installed and working.