Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@MihanEntalpo
Created August 14, 2013 10:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MihanEntalpo/6229781 to your computer and use it in GitHub Desktop.
Save MihanEntalpo/6229781 to your computer and use it in GitHub Desktop.
server
{
#redirect to https:
listen *:80;
server_name website.local;
return 301 https://$host/$1;
}
server
{
#Server name
server_name website.local;
#Use HTTPS(SSL)
listen *:443;
ssl on;
ssl_protocols SSLv3 TLSv1;
ssl_certificate /etc/nginx/ssl/cert.pem;
ssl_certificate_key /etc/nginx/ssl/cert.key;
#logs
access_log /var/log/nginx/website.local-access.log;
error_log /var/log/nginx/website.local-error.log;
#index
index index.php index.htm index.html;
#folder
root /var/www/website.local;
#Allow ajax queries to static content
error_page 405 = $uri;
#Close acces to hidden files
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
#Disable logs for robots.txt and favicon
location = /favicon.ico { log_not_found off; access_log off;
}
location = /robots.txt { allow all; log_not_found off; access_log off;
}
#main location
location / {
#Enable password protection
auth_basic_user_file /var/www/basic.passwd;
auth_basic "Enter password";
#redirect anything that doesn't exist to a index.php
try_files $uri $uri/ /index.php?$args;
}
#php file processing - using php-fpm
location ~ \.php$ {
#Include options for all php-fpm fastcgi scripts
include fastcgi_params;
try_files $uri =404;
fastcgi_pass 127.0.0.1:9999;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_ignore_client_abort off;
fastcgi_param APPLICATION_ENV devel;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment