Skip to content

Commit

Permalink
Merge branch 'release/1.0.12'
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Nov 23, 2017
2 parents 8db48e4 + 02da6af commit b21360b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Nginx-Craft Changelog

## 1.0.12 - 2017.11.23
### Added
* Added configuration for banning bots based on UserAgent

## 1.0.11 - 2017.10.02
### Added
* Added a `basic_localdev.com.conf` for people who just want a basic Nginx configuration for Craft local dev
Expand Down
17 changes: 15 additions & 2 deletions forge-example/NginxConfiguration.conf
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/SOMEDOMAIN.com/before/*;

# Ban the bots
map $http_user_agent $limit_bots {
default 0;
~*(Swiftbot|AhrefsBot|Baiduspider|DotBot|PaperLiBot) 1;
}

server {
# Listen for both IPv4 & IPv6 requests on port 443 with http2 enabled
listen 443 ssl http2;
listen [::]:443 ssl http2;

# General virtual host settings
server_name SOMEDOMAIN.com;
root /home/forge/SOMEDOMAIN.com/public;
index index.html index.htm index.php;
charset utf-8;

# Ban useless bots from crawling the site
if ($limit_bots = 1) {
return 403;
}

# 404 error handler
error_page 404 /index.php?$query_string;

Expand Down Expand Up @@ -94,7 +107,7 @@ server {
}

# php-fpm configuration
location ~ [^/]\.php(/|$) {
location ~ [^/]\.php(/|$) {
try_files $uri $uri/ /index.php?$query_string;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# Change this to whatever version of php you are using
Expand All @@ -121,7 +134,7 @@ server {
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
}
}

location ~ /\.ht {
deny all;
Expand Down
11 changes: 11 additions & 0 deletions sites-available/somedomain.com.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
# @since 1.0.0
# @license MIT

# Ban the bots
map $http_user_agent $limit_bots {
default 0;
~*(Swiftbot|AhrefsBot|Baiduspider|DotBot|PaperLiBot) 1;
}

# redirect http to https
server {
listen 80;
Expand Down Expand Up @@ -37,6 +43,11 @@ server {
index index.html index.htm index.php;
charset utf-8;

# Ban useless bots from crawling the site
if ($limit_bots = 1) {
return 403;
}

# 404 error handler
error_page 404 /index.php?$query_string;

Expand Down

0 comments on commit b21360b

Please sign in to comment.