Skip to content

Instantly share code, notes, and snippets.

@davidvanvickle
Created September 22, 2011 02:15
Show Gist options
  • Save davidvanvickle/1233871 to your computer and use it in GitHub Desktop.
Save davidvanvickle/1233871 to your computer and use it in GitHub Desktop.
Nginx conf sample
server {
listen 80;
server_name domain.com;
rewrite ^/(.*) http://www.domain.com/$1 permanent;
}
#############
server {
listen 80;
server_name dev.domain.com;
root /usr/share/nginx/www/domain_dev;
index index.php;
access_log /usr/share/nginx/www/access.log;
error_log /usr/share/nginx/www/error.log;
autoindex off;
# rewrite ^/p/(.*) /mod/p.php?args=$1 last;
# rewrite ^/help$ /help.php last;
# rewrite ^/go_home$ https://www.remote.com/redirect permanent;
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
location / {
# This is cool because no php is touched for static content
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
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/$nginx_version;
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;
}
#location ^~ /d/ {
# alias /usr/share/site/data_dev/;
#}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment