Support

Find answers, guides, and tutorials to supercharge your content delivery.

Origin Server Explained

Published on April 6, 2022
Origin Server Explained

An origin server is the first point of contact for a request made to a web page. It is responsible for delivering the initial HTML document, and all associated resources, to the user's browser. Origin servers can be public or private, depending on their intended use. In this article, we will discuss the role of an origin server in greater detail and provide tips for setting up your own.

Understanding origin servers

The purpose of an origin server is to process requests from clients and return the requested resource. This resource will be an HTML document in most cases, but it can also be other types of files, such as images or videos. Typically, they are used with an edge server or a caching server.

The origin server is the first point of contact for all requests made to a website. It is responsible for fetching the requested resource from the server's file system and returning it to the client.

Essentially, an origin server is a computer that runs web server software and stores all the files for a website. When someone types in the URL of a website, their browser sends a request to the origin server for that website. The origin server then responds by sending the requested resource back to the browser.

Hypothetically, an origin server can process every request made to a website. However, this would be inefficient and impractical. For this reason, most origin servers are configured to delegate some requests to other servers, such as an edge server or a caching server.

There are two types of origin servers: public and private. Public origin servers are typically used to serve static content, such as HTML documents and images. They work by responding to requests from any client, regardless of their location.

Private origin servers serve content that is only accessible to a specific set of users. They work by verifying the identity of each client before acting them the requested resource. They are also used to serve dynamic content like database queries and user-generated content.

Origin server vs CDN edge server

A CDN server (or CDN edge server) is a type of edge server used to distribute content from a content delivery network. It is not responsible for delivering the initial HTML document, but it can provide other types of files, such as images or videos.

Usually, an origin server will delegate some requests to a CDN edge server. This can be done in two ways: by configuring the origin server to use a CDN or by configuring the CDN to use the origin server.

Edge servers cache information to relieve pressure on origin servers. An edge server cache can decrease the time it takes for a website to load by moving static items like photos, HTML, and JavaScript files (and sometimes other content) as close as feasible to the requesting client computer.

When an origin server delegates a request to a CDN edge server, it is called "inlining". This can be done for static content, such as HTML documents and images, or dynamic content, such as database queries and user-generated content.

Here is an example of how a CDN server and an origin server work together:

  1. A user types in the URL of a website, and their browser sends a request to the CDN server.
  2. The CDN server forwards the request to the origin server.
  3. The origin server processes the request and returns the requested resource to the CDN server.
  4. The CDN server caches the resource and serves it back to the user.

Setting up an origin server

You need to take several steps to set up your own origin server.

First, you need to install web server software on your computer. The most popular web server software is Apache, but you can also use Microsoft IIS or Nginx.

Then, you need to create a website and store all the files in the correct directories. You can use any text editor to create the website, such as Notepad++ or Sublime Text.

After, you need to configure the web server software to serve the website. This usually involves editing the server's configuration file and adding some lines of code that tell the server where to find the website files and how to handle requests.

Once you do that, you need to register a domain name and point it to your server's IP address. This will allow users to access your website using a URL instead of an IP address.

Finally, you need to set up a firewall and security settings to protect your server from attacks.

Using a CDN to protect your origin server

If you want to protect your origin server from overload, you can use a CDN. A CDN will distribute the load of requests across multiple servers, which will decrease the pressure on your origin server.

In addition, a CDN can also help protect your origin server from DDoS attacks. A DDoS attack is when a malicious user sends an overwhelming amount of traffic to your server in an attempt to shut it down. A CDN can filter out this traffic and protect your server from overloading.

Can an origin server still be attacked when using a CDN?

Even though a CDN can help protect your origin server from some attacks, it is still possible for an attacker to bypass the CDN and attack your origin server directly.

This is why it is essential to have a web application firewall and security settings set up on your origin server. Doing this can make it more difficult for attackers to find and exploit vulnerabilities in your server.

You should also keep your origin server software up to date with the latest security patches. This will help protect your server from known attacks.

Can a CDN offload your origin server?

Yes, a CDN can offload your origin server by caching your content and serving it to users. This means that your origin server will not have to handle as many requests, which will decrease the load on your server.

A CDN can additionally help improve the performance of your website by delivering content from servers located close to the user. This will decrease the time it takes for the content to be delivered to the user's browser.

However, A CDN cannot offload all content delivery duties. Static files, such as images and JavaScript files, can be cached and served by the CDN, saving up to 90% of your bandwidth.

But, dynamic content, such as a PHP page that contains user input, cannot be cached and will always have to be delivered from the origin server.

Supercharge your content delivery 🚀

Try KeyCDN with a free 14 day trial, no credit card required.

Get started
KeyCDN uses cookies to make its website easier to use. Learn more