Skip to content

Instantly share code, notes, and snippets.

@tim-peterson
Created July 15, 2014 14:16
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 tim-peterson/32a67466c7c8d52ceda6 to your computer and use it in GitHub Desktop.
Save tim-peterson/32a67466c7c8d52ceda6 to your computer and use it in GitHub Desktop.
/Applications/MNPP/conf/nginx/sites-enabled/app1
server {
listen 80;
server_name notify.localhost;
return 301 http://localhost/notify$request_uri;
}
server {
listen 80;
server_name test.localhost;
return 301 http://localhost/test$request_uri;
}
server {
listen 80;
server_name localhost;
#client_max_body_size 999m; # or whatever size limit you want
#charset koi8-r;
#access_log logs/host.access.log main;
client_max_body_size 999m; # or whatever size limit you want for file upload
# Cross domain AJAX requests
add_header "Access-Control-Allow-Origin" "*";
location / {
root /Applications/MNPP/Library/nginx/html;
index index.php index.html index.htm;
}
#location ~* \.(css|js) {
# location ~* ^(.*)\.[\d]{10}\.(css|js)$ {
# ^(.*)\.[\d]{10}\.(css|js)$ $1.$2 [L]
#alias /srv/www/static/$1/$2.$3;
# try_files $1.$2;
#rewrite "/(.+)\.[\d]{10}\.(css|js)$" /$1.$2 last;
#add_header Vary Accept-Encoding;
#expires max;
# }
error_page 504 /index.php;
#error_page 404 /404.html;
#error_page 405 = @405;
#location = @405 {
#root /Applications/MNPP/Library/nginx/html;
#}
# redirect server error pages to the static page /50x.html
#
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root /Applications/MNPP/Library/nginx/html;
#}
# enforce NO www
if ($host ~* ^www\.(.*))
{
set $host_without_www $1;
rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent;
}
# canonicalize codeigniter url end points
# if your default controller is something other than "welcome" you should change the following
#if ($request_uri ~* ^(/mall(/index)?|/index(.php)?)/?$)
# {
# rewrite ^(.*)$ / permanent;
# }
# removes trailing "index" from all controllers
if ($request_uri ~* index/?$)
{
rewrite ^/(.*)/index/?$ /$1 permanent;
}
# removes trailing slashes (prevents SEO duplicate content issues)
if (!-d $request_filename)
{
rewrite ^/(.+)/$ /$1 permanent;
}
# removes access to "system" folder, also allows a "System.php" controller
if ($request_uri ~* ^/system)
{
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}
# unless the request is for a valid file (image, js, css, etc.), send to bootstrap
if (!-e $request_filename)
{
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ .php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# include fastcgi_params;
# }
# Cross domain webfont access
location ~* \.(ttf|ttc|otf|eot|woff|font.css)$ {
add_header "Access-Control-Allow-Origin" "*";
# Also, set cache rules for webfonts.
#
# See http://wiki.nginx.org/HttpCoreModule#location
# And https://github.com/h5bp/server-configs/issues/85
# And https://github.com/h5bp/server-configs/issues/86
expires 1M;
access_log off;
add_header Cache-Control "public";
}
location ~ \.php$
{
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /var/www/localhost/html$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME /Applications/MNPP/Library/nginx/html$fastcgi_script_name;
include /Applications/MNPP/conf/nginx/fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment