• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
sharadchhetri

sharadchhetri

Tutorials On Linux, Unix & Open Source

  • Home
  • Linux Commands
  • Resources
    • Learn Linux
  • My WordPress plugins

Configure Nginx for Jekyll / Octopress / pelican based static website

December 13, 2014 by Sharad Chhetri

This post explain, how to configure Nginx web server for Static Website. At the current time, Jekyll,Octopress, pelican are very popular static site generator. Generally for static website we use html files.

Note: This post share the Nginx Configuration file settings for static website.

We worked on couple of website which were generated with Jekyll,Octopress and pelican.In this post we are sharing the Nginx configuration file for static website.

We have added some feature in this Nginx configuration file which will help your Nginx site to load quickly. These features are given below –

1. Enable compression
2. Enable Leverage Browsing

We believe you have already install Nginx on your system (Install Nginx on CentOS 7)

Given below is the Nginx Configuration file settings –
Replace example.com with your domain name.

server {

    ## Give Domain name
    server_name example.com www.example.com;

    ## Define custom path for Nginx site log
    access_log /var/log/nginx/example.com-access.log;
    error_log /var/log/nginx/example.com-error.log;

    ## Give absolute path of Web root where your website files/dir are saved
    root /usr/local/nginx/html/examplecom_octopress;

    ## Define the index file
    index index.html;
    autoindex off;

    ## Setting Compression
  
    gzip on;
    gzip_disable "msie6";
    gzip_min_length 1100;
    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 6;
    gzip_buffers 16 8k;
    gzip_http_version 1.1;
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    ## Define 404 pages URL
    location / {
     try_files $uri $uri/ =404; 

   }

    # Disable favicon.ico logging
    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    # Allow robots and disable logging
    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }


    # Disable static content logging and set cache time to max
    location ~* .(js|css|png|jpg|jpeg|gif|ico)$ {
        expires 365d;
        log_not_found off;
    }

    # Deny access to htaccess and htpasswd files
    location ~ /.ht {
        deny  all;
    }
}

After saving the file.Run the command nginx -t , to check if any error in configuration file

Restart the Nginx Service.

On CentOS 7 / RHEL 7

systemctl restart nginx

On CentOS 5,6 / RHEL 5,6

service nginx restart

On Debian / Ubuntu

sudo service nginx restart

OR

sudo /etc/init.d/nginx restart

Share this:

  • Twitter
  • Facebook
  • More
  • Print
  • Email
  • LinkedIn
  • Reddit
  • Tumblr
  • Pinterest
  • Pocket
  • Telegram
  • WhatsApp
  • Mastodon

Related posts:

  1. How to configure static ip address through command line in Ubuntu
  2. Install Jekyll on Ubuntu 14.04 LTS
  3. How To Add duckduckgo Search engine in WordPress Blog or website
  4. Convert website page to pdf and image
  5. Can’t load ‘/usr/local/lib64/perl5/auto/nginx/nginx.so’
  6. How to install Octopress in CentOS 6 and RHEL 6
  7. How to change Port number for Octopress rake preview
  8. show post excerpt in atoms feed of octopress
  9. Octopress : Could not find a JavaScript runtime
  10. How to install Octopress on Ubuntu 14.04 LTS

Filed Under: Linux Tagged With: nginx

Primary Sidebar

Our Social Media Presence

  • Facebook
  • GitHub
  • Twitter

Linux Command

What is Linux Internal And External Command

Linux Basic Commands With Examples For Every Beginner

tr command to convert lines to space , tab and vertical tab

smbpasswd command not found on CentOS 7 and RHEL 7

Solution : semanage command not found

Unix / Linux : How to print duplicate lines from file

More Posts from this Category

You Might Like These Articles!

simplecodesyntax wordpress plugin

SimpleCodeSyntax : My Another WordPress Plugin

Install Nginx

How To Install Nginx On Ubuntu 22.04 LTS

Install Latest Git package in Ubuntu Operating System

How To Always Install Latest Git Package In Ubuntu Operating System

Bash script for installing VirtualBox on Ubuntu 22.04 LTS Desktop

Install VirtualBox On Ubuntu 22.04 LTS Desktop (Bash Script)

libfuse

dlopen(): error loading libfuse.so.2 – Got Error On Ubuntu

Failed to open/create the internal network

VirtualBox Error: Failed to open/create the internal network

Always Useful Tips And Tricks

Edit the crontab without using crontab -e

send email after mysql backup through bash script in simple way

How to install pam_mysql in CentOS or Red Hat

How to change hostname in Ubuntu 12.04 and 12.10 without system restart

error command ‘gcc’ failed with exit status 1 in Ubuntu

Nagios HTTP WARNING: HTTP/1.1 403 Forbidden

Change the default port number of ssh server

Explore 90+ Article On "Linux Tips And Tricks"

Copyright © 2023 ยท
The material in this site cannot be republished either online or offline, without our permission.
Proudly Blogging From Bharat.

  • Contact
  • About Me
  • My WordPress plugins
  • Privacy Policy