Added support for wildcards in nginx proxy and updated laradev to use subdomains for branches"
This commit is contained in:
parent
2a22d854d6
commit
d582195141
7 changed files with 66 additions and 5 deletions
|
@ -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
|
||||
|
|
37
states/roles/maintain/laradev/branch.conf
Normal file
37
states/roles/maintain/laradev/branch.conf
Normal file
|
@ -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;
|
||||
}
|
|
@ -8,6 +8,8 @@ branches=`git ls-remote {{repo}} | grep -o -P "(?<=refs/heads/).*"`
|
|||
echo "Branches:<br/>" > /sites/{{project}}/index.php
|
||||
for branch in $branches; do
|
||||
echo " <a href='$branch/public/'>$branch<br/>" >> /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 " <a href='$branch/public/'>$branch<br/>" >> /sites/{{project}}/index.php
|
|||
done
|
||||
chown http:http "/sites/{{project}}" -R
|
||||
{%- endfor -%}
|
||||
systemctl restart nginx
|
||||
{% endif %}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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";
|
||||
|
|
Loading…
Add table
Reference in a new issue