Skip to content

Instantly share code, notes, and snippets.

@morales2k
Last active December 14, 2017 22:49
Show Gist options
  • Select an option

  • Save morales2k/bce5e4af2cd0b6a97737c78c13d7367e to your computer and use it in GitHub Desktop.

Select an option

Save morales2k/bce5e4af2cd0b6a97737c78c13d7367e to your computer and use it in GitHub Desktop.

Revisions

  1. morales2k revised this gist Dec 14, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion serve-ngrokEnabled.sh
    Original file line number Diff line number Diff line change
    @@ -24,7 +24,7 @@ fi

    if test "${params['ngrokName']+isset}"
    then
    echo "${params[ngrokName]} will be added to \[$1\] server name"
    echo "${params[ngrokName]} will be added to \"$1\" server name"
    else
    params['ngrokName']=""
    fi
  2. morales2k revised this gist Dec 12, 2017. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions serve-ngrokEnabled.sh
    Original file line number Diff line number Diff line change
    @@ -8,6 +8,9 @@
    # add it to server_name if it exists. This will only
    # execute on sites that are of type: ngrokEnabled
    ###
    # The ngrok command I use to run share these sites is as follows:
    # ngrok http mydev.test:80 --subdomain={WHATEVER_YOU_WANT_TO_USE}
    ###

    declare -A params=$6 # Create an associative array
    paramsTXT=""
  3. morales2k revised this gist Dec 12, 2017. No changes.
  4. morales2k created this gist Dec 12, 2017.
    38 changes: 38 additions & 0 deletions Homestead.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    ---
    ip: "10.10.192.168"
    memory: 2048
    cpus: 1
    provider: virtualbox
    name: homestead-7

    authorize: ~/.ssh/id_rsa.pub

    keys:
    - ~/.ssh/id_rsa

    folders:
    - map: ~/www
    to: /home/vagrant/Code

    sites:
    - map: mydev.test
    to: /home/vagrant/Code/test/public
    type: ngrokEnabled
    params:
    - key: ngrokName
    value: {WHATEVER_YOU_WANT_TO_USE}.ngrok.io
    databases:
    - Homestead

    # blackfire:
    # - id: foo
    # token: bar
    # client-id: foo
    # client-token: bar

    # ports:
    # - send: 50000
    # to: 5000
    # - send: 7777
    # to: 777
    # protocol: udp
    79 changes: 79 additions & 0 deletions serve-ngrokEnabled.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,79 @@
    #!/usr/bin/env bash

    ###
    # Homestead/scripts/serve-ngrokEnabled.sh
    ###
    # This is a copy, basically, of the serve-laravel.sh script,
    # but modded to look for my custom param (ngrokName) and
    # add it to server_name if it exists. This will only
    # execute on sites that are of type: ngrokEnabled
    ###

    declare -A params=$6 # Create an associative array
    paramsTXT=""
    if [ -n "$6" ]; then
    for element in "${!params[@]}"
    do
    paramsTXT="${paramsTXT}
    fastcgi_param ${element} ${params[$element]};"
    done
    fi

    if test "${params['ngrokName']+isset}"
    then
    echo "${params[ngrokName]} will be added to \[$1\] server name"
    else
    params['ngrokName']=""
    fi

    block="server {
    listen ${3:-80};
    listen ${4:-443} ssl http2;
    server_name $1 ${params[ngrokName]};
    root \"$2\";
    index index.html index.htm index.php;
    charset utf-8;
    location / {
    try_files \$uri \$uri/ /index.php?\$query_string;
    }
    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt { access_log off; log_not_found off; }
    access_log off;
    error_log /var/log/nginx/$1-error.log error;
    sendfile off;
    client_max_body_size 100m;
    location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php/php$5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
    $paramsTXT
    fastcgi_intercept_errors off;
    fastcgi_buffer_size 16k;
    fastcgi_buffers 4 16k;
    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;
    }
    location ~ /\.ht {
    deny all;
    }
    ssl_certificate /etc/nginx/ssl/$1.crt;
    ssl_certificate_key /etc/nginx/ssl/$1.key;
    }
    "

    echo "$block" > "/etc/nginx/sites-available/$1"
    ln -fs "/etc/nginx/sites-available/$1" "/etc/nginx/sites-enabled/$1"