• 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 Leave a Comment

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 change Port number for Octopress rake preview
  7. show post excerpt in atoms feed of octopress
  8. Print double hyphen sign simultaneously in post 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

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Our Social Media Presence

  • Facebook
  • GitHub
  • Twitter

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Linux Commands

Linux Basic Commands For Every Beginner

Allow only members of Wheel group to use su command on RHEL/CentOS

How to rename and move the directory and files in linux

Yum command to download rpm file without installing in linux system

Find exit status code of last executed command on Linux and Unix

Useful tail command with examples in Linux/Unix

vi : Edit file without opening it

Explore 70+ Articles On Linux Commands

Always Useful Tips And Tricks

Print double hyphen sign simultaneously in post of Octopress

Run the script using nohup without hitting enter key two times

How to forcefully send mail from mailq in sendmail MTA

Read the file inside compressed .gz files without extract

How to backup and restore iptables on Linux systems

Edit the crontab without using crontab -e

Convert hyphen to underscore in between all filenames shell script

Explore 90+ Article On "Linux Tips And Tricks"

You Might Like These Articles!

Internal External Command

What is Linux/Unix Internal And External Command

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

Copyright © 2023 ยท
The material in this site cannot be republished either online or offline, without our permission but Schools and Colleges can do in their Private Network
Proudly Blogging From Bharat.

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