From d4c21371069c4229dce7fc4316a1dea6d6e882e9 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 23 Jul 2020 19:53:57 +0100 Subject: [PATCH] Use unix domain sockets for FPM on dev --- cookbooks/dev/recipes/default.rb | 6 +----- cookbooks/dev/templates/default/apache.phppgadmin.erb | 6 +++--- cookbooks/dev/templates/default/apache.user.erb | 5 +++-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/cookbooks/dev/recipes/default.rb b/cookbooks/dev/recipes/default.rb index 30d26f910..1888e9cdd 100644 --- a/cookbooks/dev/recipes/default.rb +++ b/cookbooks/dev/recipes/default.rb @@ -94,7 +94,6 @@ end package "apache2-suexec-pristine" php_fpm "default" do - port 7000 pm_max_children 10 pm_start_servers 4 pm_min_spare_servers 2 @@ -159,10 +158,7 @@ search(:accounts, "*:*").each do |account| next unless File.directory?("#{user_home}/public_html") - port_number = 7000 + account["uid"].to_i - php_fpm name do - port port_number user name group name pm_max_children 10 @@ -193,7 +189,7 @@ search(:accounts, "*:*").each do |account| apache_site "#{name}.dev.openstreetmap.org" do template "apache.user.erb" directory "#{user_home}/public_html" - variables :user => name, :port => port_number + variables :user => name end template "/etc/sudoers.d/#{name}" do diff --git a/cookbooks/dev/templates/default/apache.phppgadmin.erb b/cookbooks/dev/templates/default/apache.phppgadmin.erb index ec74a54da..2965946e2 100644 --- a/cookbooks/dev/templates/default/apache.phppgadmin.erb +++ b/cookbooks/dev/templates/default/apache.phppgadmin.erb @@ -16,9 +16,9 @@ # Remove Proxy request header to mitigate https://httpoxy.org/ RequestHeader unset Proxy early - ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:7000/usr/share/phppgadmin - ProxyPassMatch ^/(.*\.phpx(/.*)?)$ fcgi://127.0.0.1:7000/usr/share/phppgadmin - ProxyPassMatch ^/(.*\.phpj(/.*)?)$ fcgi://127.0.0.1:7000/usr/share/phppgadmin + ProxyPassMatch ^/(.*\.php(/.*)?)$ unix:/run/php/default.sock|fcgi://127.0.0.1 + ProxyPassMatch ^/(.*\.phpx(/.*)?)$ unix:/run/php/default.sock|fcgi://127.0.0.1 + ProxyPassMatch ^/(.*\.phpj(/.*)?)$ unix:/run/php/default.sock|fcgi://127.0.0.1 diff --git a/cookbooks/dev/templates/default/apache.user.erb b/cookbooks/dev/templates/default/apache.user.erb index a6d4d8866..d308e5977 100644 --- a/cookbooks/dev/templates/default/apache.user.erb +++ b/cookbooks/dev/templates/default/apache.user.erb @@ -29,8 +29,9 @@ WSGIDaemonProcess <%= @user %>.dev.openstreetmap.org user=<%= @user %> inactivit RewriteCond <%= @directory %>%{REQUEST_FILENAME} -f RewriteRule ^/cgi-bin/(.*)$ /~<%= @user %>/cgi-bin/$1 [PT,L] - RewriteCond <%= @directory %>%{REQUEST_FILENAME} -f - RewriteRule ^/(.*\.ph(p|ps|p3|tml)(/.*)?)$ fcgi://127.0.0.1:<%= @port %><%= @directory %>/$1 [P] + + SetHandler "proxy:unix:/run/php/tomh.sock|fcgi://127.0.0.1" + -- 2.39.5