Skip to content

Instantly share code, notes, and snippets.

@drparham
Last active August 29, 2015 14:20
Show Gist options
  • Save drparham/acb24a782b4ffc735796 to your computer and use it in GitHub Desktop.
Save drparham/acb24a782b4ffc735796 to your computer and use it in GitHub Desktop.
location = /robots.txt { access_log off; log_not_found off; }
location = /favicon.ico { access_log off; log_not_found off; }
location ~ /\. { access_log off; log_not_found off; deny all; }
location ~ ~$ { access_log off; log_not_found off; deny all; }
server {
listen 80;
server_name domain.tld;
server_tokens off;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name domain.tld$;
server_tokens off;
root /var/www/public_html/domain.tld/public;
ssl on;
ssl_certificate /etc/nginx/ssl/domain/ssl-bundle.crt;
ssl_certificate_key /etc/nginx/ssl/domain/domain.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers AES:HIGH:!ADH:!MDF;
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/$domain.stage.promocampaigns.com.access.log;
error_log /var/log/nginx/$domain.stage.promocampaigns.com.error.log;
location / {
# Rewrite rules and other criterias can go here
# Remember to avoid using if() where possible (http://wiki.nginx.org/IfIsEvil)
try_files $uri $uri/ /index.php?$args;
index index.php index.html index.htm;
#rewrite ^ /index.php last;
}
location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
# Some basic cache-control for static files to be sent to the browser
expires max;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
include drop.conf;
include php.conf;
}
location ~ \.php {
# for security reasons the next line is highly encouraged
try_files $uri =404;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
# Enables Laravel to detect if it's HTTP/HTTPS
# Don't enable for WordPress Servers
fastcgi_param HTTPS on;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
# if the next line in yours still contains $document_root
# consider switching to $request_filename provides
# better support for directives such as alias
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# If using a unix socket...
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_read_timeout 300;
# If using a TCP connection...
#fastcgi_pass 127.0.0.1:9000;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment