Skip to content

Instantly share code, notes, and snippets.

@mnshankar
Last active March 16, 2023 11:17

Revisions

  1. mnshankar revised this gist Mar 22, 2014. 1 changed file with 8 additions and 2 deletions.
    10 changes: 8 additions & 2 deletions nginx.conf
    Original file line number Diff line number Diff line change
    @@ -10,6 +10,12 @@ server {
    error_log /var/log/nginx/vagrant.com-error.log error;

    charset utf-8;

    # handle static files within project.. break at end to avoid recursive redirect
    location ~project(\d*)/((.*)\.(?:css|cur|js|jpg|jpeg|gif|htc|ico|png|html|xml))$ {
    rewrite project(\d*)/((.*)\.(?:css|cur|js|jpg|jpeg|gif|htc|ico|png|html|xml))$ /project$1/public/$2 break;
    }

    #project1 and project2 are two laravel projects that you want to serve
    # at http://192.168.33.10.xip.io/project1/ and http://192.168.33.10.xip.io/project2/ respectively
    location /project1{
    @@ -34,9 +40,9 @@ server {
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    ############# IMPORTANT - This section adjusts the request URI to laravel ######################
    ############# IMPORTANT - This section adjusts the request URI sent to laravel #################
    set $laravel_uri $request_uri;
    if ($request_uri ~ ^/project(.*)/(.*)$ ) {
    if ($laravel_uri ~ project(\d*)(/?.*)$) {
    set $laravel_uri $2;
    }
    ###################### Note request uri mod below ##############################################
  2. mnshankar revised this gist Mar 19, 2014. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions nginx.conf
    Original file line number Diff line number Diff line change
    @@ -35,12 +35,12 @@ server {
    fastcgi_index index.php;
    include fastcgi_params;
    ############# IMPORTANT - This section adjusts the request URI to laravel ######################
    set $request_url $request_uri;
    set $laravel_uri $request_uri;
    if ($request_uri ~ ^/project(.*)/(.*)$ ) {
    set $request_url $2;
    set $laravel_uri $2;
    }
    ###################### Note request uri mod below ##############################################
    fastcgi_param REQUEST_URI $request_url;
    fastcgi_param REQUEST_URI $laravel_uri;
    fastcgi_param LARA_ENV local; # Environment variable for Laravel
    fastcgi_param HTTPS off;
    }
  3. mnshankar renamed this gist Mar 19, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. mnshankar created this gist Mar 19, 2014.
    51 changes: 51 additions & 0 deletions vagrant.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,51 @@
    server {
    listen 80;
    root /vagrant;
    index index.html index.htm index.php app.php app_dev.php;

    # Make site accessible from http://set-ip-address.xip.io
    server_name 192.168.33.10.xip.io;

    access_log /var/log/nginx/vagrant.com-access.log;
    error_log /var/log/nginx/vagrant.com-error.log error;

    charset utf-8;
    #project1 and project2 are two laravel projects that you want to serve
    # at http://192.168.33.10.xip.io/project1/ and http://192.168.33.10.xip.io/project2/ respectively
    location /project1{
    rewrite ^/project1/(.*)$ /project1/public/index.php?$1 last;
    }

    location /project2 {
    rewrite ^/project2/(.*)$ /project2/public/index.php?$1 last;
    }

    location = /favicon.ico { log_not_found off; access_log off; }
    location = /robots.txt { access_log off; log_not_found off; }

    error_page 404 /index.php;

    # pass the PHP scripts to php5-fpm
    # Note: \.php$ is susceptible to file upload attacks
    # Consider using: "location ~ ^/(index|app|app_dev|config)\.php(/|$) {"
    location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    # With php5-fpm:
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    ############# IMPORTANT - This section adjusts the request URI to laravel ######################
    set $request_url $request_uri;
    if ($request_uri ~ ^/project(.*)/(.*)$ ) {
    set $request_url $2;
    }
    ###################### Note request uri mod below ##############################################
    fastcgi_param REQUEST_URI $request_url;
    fastcgi_param LARA_ENV local; # Environment variable for Laravel
    fastcgi_param HTTPS off;
    }
    # Deny .htaccess file access
    location ~ /\.ht {
    deny all;
    }
    }