Skip to content

Instantly share code, notes, and snippets.

@RoesWibowo
Created August 21, 2016 04:58
Show Gist options
  • Save RoesWibowo/dc2e6c9166383569c35953a267b3d5a5 to your computer and use it in GitHub Desktop.
Save RoesWibowo/dc2e6c9166383569c35953a267b3d5a5 to your computer and use it in GitHub Desktop.
Example nginx with alias without subdomain
server {
listen 80 deferred;
server_name server.com;
index index.php;
charset utf-8;
# App 1 (main app)
location / {
root /var/www/app1/current/public;
try_files $uri $uri/ /index.php?$query_string;
error_log /var/log/nginx/app1.notice.log notice;
error_log /var/log/nginx/app1.error.log error;
location ~* ^/index\.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/www/app1/current/public/index.php;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
}
}
# App 2
location ~* /app2 {
alias /var/www/app2/current/public;
try_files $uri $uri/ /app2/index.php?$query_string;
error_log /var/log/nginx/app2.notice.log notice;
error_log /var/log/nginx/app2.error.log error;
location ~* ^/app2/index\.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/www/app2/current/public/index.php;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
}
}
# Files
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
# Error
access_log off;
rewrite_log on;
# Disable .htaccess access
location ~ /\.ht {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment