Skip to content

Instantly share code, notes, and snippets.

@adamamyl
Created January 17, 2013 15:38
Show Gist options
  • Save adamamyl/4556825 to your computer and use it in GitHub Desktop.
Save adamamyl/4556825 to your computer and use it in GitHub Desktop.
nginx + php-fpm + SSL
server {
server_name rewiredreality.co.uk;
root "/data/vhosts/rewiredreality.co.uk/current/html";
listen 188.246.207.224:443 ssl;
ssl on;
ssl_certificate /data/vhosts/rewiredreality.co.uk/rewiredreality-deployment/ssl-certs/rewiredreality.co.uk-crt;
ssl_certificate_key /data/vhosts/rewiredreality.co.uk/rewiredreality-deployment/ssl-certs/rewiredreality.co.uk-key;
ssl_client_certificate /data/vhosts/rewiredreality.co.uk/rewiredreality-deployment/ssl-certs/GandiStandardSSLCA.crt;
index index.php;
client_max_body_size 10m;
access_log /data/vhosts/rewiredreality.co.uk/logs/access.log;
error_log /data/vhosts/rewiredreality.co.uk/logs/error.log;
if ($http_user_agent ~* (Baiduspider|webalta|nikto|wkito|pikto|scan|acunetix|morfeus|webcollage|youdao) ) {
return 401;
}
if ($http_user_agent ~* (HTTrack|clshttp|archiver|loader|email|harvest|extract|grab|miner) ) {
return 401;
}
location / {
try_files $uri $uri/ /index.php$uri?$args;
}
location ~ "^(.+\.php)($|/)" {
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SERVER_NAME $host;
if ($uri !~ "^/uploads/") {
fastcgi_pass unix:/var/run/php-fpm/rewiredreality_fpm.sock;
}
include fastcgi_params;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
access_log off;
}
location ~* \.(html|htm)$ {
expires 30m;
}
location ~* /\.(ht|git|svn) {
deny all;
}
}
# Redirector
server {
# see: http://wiki.nginx.org/HttpCoreModule#server_name
server_name www.rewiredreality.co.uk rewiredreality.* www.rewiredreality.*;
return 301 https://rewiredreality.co.uk$request_uri;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment