diff --git a/pillars/roles/nginx/clark-family.sls b/pillars/roles/nginx/clark-family.sls
index 400ed44..92fcd2c 100644
--- a/pillars/roles/nginx/clark-family.sls
+++ b/pillars/roles/nginx/clark-family.sls
@@ -4,6 +4,7 @@ nginx:
https:
port: 8080
prot: http
+ wildcard: true
portal:
Dev:
@@ -11,3 +12,4 @@ portal:
name: Clark Family Genealogy
summary: Clark Family Genealogy Dev Site
public: false
+ wildcard: true
diff --git a/states/roles/maintain/laradev/branch.conf b/states/roles/maintain/laradev/branch.conf
new file mode 100644
index 0000000..a2ae53b
--- /dev/null
+++ b/states/roles/maintain/laradev/branch.conf
@@ -0,0 +1,37 @@
+server {
+ listen 8080;
+ server_name -branch-.-server-.actcur.com;
+ root /sites/-server-/-branch-/public;
+
+ index index.html index.htm index.php;
+
+ charset utf-8;
+
+ rewrite_log on;
+
+ location @laravel {
+ rewrite ^(/[^/]+/[^/]+)/(.*)$ $1/index.php?$2 last;
+ }
+
+ location / {
+ try_files $uri $uri/ @laravel;
+ }
+
+ location = /favicon.ico { access_log off; log_not_found off; }
+ location = /robots.txt { access_log off; log_not_found off; }
+
+ error_page 404 /index.php;
+
+ location ~ \.php$ {
+ fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
+ fastcgi_index index.php;
+ fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
+ include fastcgi_params;
+ }
+
+ location ~ /\.(?!well-known).* {
+ deny all;
+ }
+ error_log /var/log/nginx/ra_error.log notice;
+ access_log /var/log/nginx/ra_access.log;
+}
diff --git a/states/roles/maintain/laradev/git_branches.sh b/states/roles/maintain/laradev/git_branches.sh
index 12fd912..4aec2df 100644
--- a/states/roles/maintain/laradev/git_branches.sh
+++ b/states/roles/maintain/laradev/git_branches.sh
@@ -8,6 +8,8 @@ branches=`git ls-remote {{repo}} | grep -o -P "(?<=refs/heads/).*"`
echo "Branches:
" > /sites/{{project}}/index.php
for branch in $branches; do
echo " $branch
" >> /sites/{{project}}/index.php
+ #create/update nginx conf file
+ sed -e "s/-branch-/$branch/" -e "s/-server-/{{project}}/" /root/scripts/laradev-branch-nginx.template > /etc/nginx/conf.d/laradev-{{project}}-$branch.conf
#clone new branch if necessary
if [ ! -d "$branch" ];then
git clone -b $branch {{repo}} "$branch"
@@ -41,4 +43,5 @@ echo " $branch
" >> /sites/{{project}}/index.php
done
chown http:http "/sites/{{project}}" -R
{%- endfor -%}
+systemctl restart nginx
{% endif %}
diff --git a/states/roles/maintain/laradev/init.sls b/states/roles/maintain/laradev/init.sls
index ebeecce..52043a9 100644
--- a/states/roles/maintain/laradev/init.sls
+++ b/states/roles/maintain/laradev/init.sls
@@ -101,6 +101,13 @@ laradev-nginx-conf:
- template: jinja
password: "{%- include 'secure/passwords/laradev_db_password.txt' -%}"
+/root/scripts/laradev-branch-nginx.template:
+ file.managed:
+ - source: salt://roles/maintain/laradev/branch.conf
+ - user: root
+ - group: root
+ - mode: 644
+
"/lib/systemd/system/git_branches.service":
file.managed:
- source: salt://roles/maintain/laradev/git_branches.service
diff --git a/states/roles/maintain/laradev/nginx.conf b/states/roles/maintain/laradev/nginx.conf
index 8ed5fa4..db1a352 100644
--- a/states/roles/maintain/laradev/nginx.conf
+++ b/states/roles/maintain/laradev/nginx.conf
@@ -1,7 +1,7 @@
server {
listen 8080;
- server_name {{server}};
- root /sites/{{server}};
+ server_name {{server}}.actcur.com;
+ root /sites/{{server}}/prod/public;
index index.html index.htm index.php;
diff --git a/states/roles/maintain/nginx-proxy/local.conf b/states/roles/maintain/nginx-proxy/local.conf
index e784ad0..d5484b0 100644
--- a/states/roles/maintain/nginx-proxy/local.conf
+++ b/states/roles/maintain/nginx-proxy/local.conf
@@ -3,6 +3,12 @@
{%- else -%}
{%- set default = "yes" -%}
{%- endif -%}
+{%- set wildcard = "" -%}
+{%- if pillar['nginx'][server]['wildcard'] is defined -%}
+ {%- if pillar['nginx'][server]['wildcard'] -%}
+ {%- set wildcard = "*." ~ server ~ ".actcur.com" -%}
+ {%- endif -%}
+{%- endif -%}
{%- if pillar['nginx'][server]['https'] is defined -%}
{%- if pillar['nginx'][server]['https']['port'] is defined-%}
{%- set port = pillar['nginx'][server]['https']['port'] -%}
@@ -14,10 +20,10 @@
{%- endif -%}
server {
listen 443;
- server_name {{server}}.actcur.com;
+ server_name {{server}}.actcur.com {{wildcard}};
resolver {{ resolver }};
- set $backend "{{prot}}://{{server}}.actcur.com{%- if port is defined -%}:{{port}}{%- endif -%}";
+ set $backend "{{prot}}://$server_name{%- if port is defined -%}:{{port}}{%- endif -%}";
ssl on;
ssl_certificate /etc/nginx/certs/{{server}}.actcur.com/fullchain.pem;
diff --git a/states/roles/maintain/nginx-proxy/remote.conf b/states/roles/maintain/nginx-proxy/remote.conf
index 951d33f..9bccdd8 100644
--- a/states/roles/maintain/nginx-proxy/remote.conf
+++ b/states/roles/maintain/nginx-proxy/remote.conf
@@ -4,10 +4,16 @@
{%- set auth = pillar['nginx'][server]['auth'] -%}
{%- endif -%}
{%- endif -%}
+{%- set wildcard = "" -%}
+{%- if pillar['nginx'][server]['wildcard'] is defined -%}
+ {%- if pillar['nginx'][server]['wildcard'] -%}
+ {%- set wildcard = "*." ~ server ~ ".actcur.com" -%}
+ {%- endif -%}
+{%- endif -%}
server {
listen 443;
- server_name {{server}}.actcur.com;
+ server_name {{server}}.actcur.com {{wildcard}};
resolver {{resolver}};
set $backend "https://{{server}}.actcur.com";