server {
listen 80;
server_name www.justsayapple.com justsayapple.com www.justsayapple.net justayapple.net;
return 301 http://sayapple.com$request_uri;
}
server {
listen 80;
server_name www.apple4me.net apple4me.net;
return 301 http://sayapple.com$request_uri;
}
server {
listen 80 default_server;
server_name sayapple.com;
rewrite ^/(.*)/favicon.ico$ /favicon.ico last;
error_log /var/log/nginx/apple-error.log warn;
access_log /var/log/nginx/apple-access.log;
root /var/www/apple4me;
location /symlinktophpmyadmin {
auth_basic "Restricted";
auth_basic_user_file /my/secret/sauce/ht.password;
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/symlinktophpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
location ~* ^/symlinktophpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$
{
root /usr/share/;
}
}
location /SymLinkToPhpMyAdmin {
rewrite ^/* /symlinktophpmyadmin last;
}
location /images/ {
expires max;
}
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
allow 199.48.164.104;
allow 24.49.69.204;
deny all;
}
location /install {
auth_basic "Administrator Login";
auth_basic_user_file /my/secret/sauce/ht.password;
}
location = /admin.php {
auth_basic "Just Say Apple Administrator Login";
auth_basic_user_file /my/secret/sauce/ht.password;
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
location / {
## Deny certain User-Agents (case insensitive)
## The ~* makes it case insensitive as opposed to just a ~
if ($http_user_agent ~* (Baidu|Ahrefsbot|Morfeus|ZmEu|Baiduspider|Jullo|Yandex|Sogou) ) {
return 444;
}
#This sends everything through index.php and keeps the appended
#query string intact.
try_files $uri $uri/ /index.php?$uri&$args;
index index.php index.html index.htm;
rewrite /(robots.txt)$ /robots.php last;
#gzip it, gzip it good
gzip on;
gzip_http_version 1.1;
gzip_vary on;
gzip_min_length 1100;
gzip_buffers 64 8k;
gzip_comp_level 2;
gzip_proxied any;
gzip_types image/png image/gif image/jpeg image/jpg text/xml text/plain text/css application/json application/x-javascript application/vnd.ms-fontobject application/x-font-
ttf font/opentype application/xml application/rss+xml application/atom+xml application/rdf+xml;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
}
# use fastcgi for all php files
location ~ \.php$ {
# Zero-day exploit defense.
# http://forum.nginx.org/read.php?2,88845,page=3
try_files $uri /index.php =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_ignore_client_abort off;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
# Feed
location ~* \.(?:rss|atom)$ {
expires 1h;
add_header Cache-Control "public";
}
# Media: images, icons, video, audio, HTC
location ~* \.(?:jpg|jpeg|gif|png|ico|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
expires 1M;
access_log off;
add_header Cache-Control "public";
}
# CSS and Javascript
location ~* \.(?:css|js)$ {
expires 1y;
access_log off;
add_header Cache-Control "public";
}
# WebFonts
# If you are NOT using cross-domain-fonts.conf, uncomment the following directive
location ~* \.(?:ttf|ttc|otf|eot|woff|font.css)$ {
expires 1M;
access_log off;
add_header Cache-Control "public";
}
location /internal_data {
location ~ \.(data|html|php)$ {
internal;
}
internal;
}
location /library {
location ~ \.(default|html|php|txt|xml)$ {
internal;
}
internal;
}
# deny access to apache .htaccess files
location ~ /\.ht
{
deny all;
}
}