Skip to content

Instantly share code, notes, and snippets.

@grEvenX
Created May 24, 2012 14:27
Show Gist options
  • Save grEvenX/2781880 to your computer and use it in GitHub Desktop.
Save grEvenX/2781880 to your computer and use it in GitHub Desktop.
nginx multi-project based on base-path
server {
listen 443;
server_name mysuperserver;
location /project1 {
}
location /project2 {
}
}
#Project1 server
server {
server_name project1;
root /var/www/project1;
if (!-e $request_filename) {
rewrite ^/(.+)$ /index.php?url=$1 last;
break;
}
location ~ index\.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_intercept_errors on; # to support 404s for PHP files not found
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
location ~* \favicon.ico$ {
access_log off;
expires 1d;
add_header Cache-Control public;
}
}
#Project2 server
server {
server_name project2;
root /var/www/project2;
if (!-e $request_filename) {
rewrite ^/(.+)$ /index.php?url=$1 last;
break;
}
location ~ index\.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_intercept_errors on; # to support 404s for PHP files not found
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
location ~* \favicon.ico$ {
access_log off;
expires 1d;
add_header Cache-Control public;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment