[Rt-commit] rt branch 5.0/test-apache-proxy-fcgi created. rt-5.0.4-23-gaeab793484

BPS Git Server git at git.bestpractical.com
Wed Jun 14 20:43:36 UTC 2023


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".

The branch, 5.0/test-apache-proxy-fcgi has been created
        at  aeab7934845a2372e36bcaf461deab0e81dd7bee (commit)

- Log -----------------------------------------------------------------
commit aeab7934845a2372e36bcaf461deab0e81dd7bee
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Jun 9 04:37:35 2023 +0800

    Document web deployment with apache+proxy_fcgi

diff --git a/docs/web_deployment.pod b/docs/web_deployment.pod
index 6ee03d48d8..22c2ef30f5 100644
--- a/docs/web_deployment.pod
+++ b/docs/web_deployment.pod
@@ -32,22 +32,20 @@ C<mod_speling> will cause RT's CSS and JS to not be loaded, making RT
 appear unstyled. C<mod_cache> will cache cookies, making users be
 spontaneously logged in as other users in the system.
 
-See also L<authentication/Apache configuration>, in case you intend to
+See also L<authentication/Apache Configuration>, in case you intend to
 use Apache to provide authentication.
 
-=head3 prefork MPM
+=head3 mod_fcgid
 
 Apache can run with several different
 L<Multi-Processing Modules (MPMs)|https://httpd.apache.org/docs/2.4/mpm.html>.
-RT is designed to run only with the L<prefork MPM|https://httpd.apache.org/docs/2.4/mod/prefork.html>.
+To use mod_fcgid, you need to run it with the L<prefork MPM|https://httpd.apache.org/docs/2.4/mod/prefork.html>.
 Most Linux distributions today use the event MPM by default, so it is
 important to make sure Apache is configured to use prefork on your RT
 server. If you do not use prefork MPM, RT will start okay but fail under
 production load, either because the web server crashes or performance
 severely degrades.
 
-=head3 mod_fcgid
-
 B<WARNING>: Before mod_fcgid 2.3.6, the maximum request size was 1GB.
 Starting in 2.3.6, this is now 128Kb.  This is unlikely to be large
 enough for any RT install that handles attachments.  You can read more
@@ -80,6 +78,35 @@ to return to the old default.
         </Location>
     </VirtualHost>
 
+=head3 mod_proxy_fcgi
+
+This Apache module supports proxying requests via the FastCGI protocol.
+In addition to running Apache, you also need to start RT FCGI processes
+separately with a command like this:
+
+    /opt/rt5/sbin/rt-server.fcgi --listen /opt/rt5/var/rt.sock --nproc 10
+
+In this configuration, RT runs with L<Plack::Handler::FCGI> and supports any
+arguments documented there.
+
+Below is the corresponding Apache configuration:
+
+    <VirtualHost rt.example.com>
+        AddDefaultCharset UTF-8
+
+        ProxyPass / unix:/opt/rt5/var/rt.sock|fcgi://localhost/
+        ProxyFCGIBackendType GENERIC
+        ProxyFCGISetEnvIf "true" SCRIPT_NAME ""
+    </VirtualHost>
+
+Note that the SCRIPT_NAME directive is needed to avoid issues with URIs not
+being properly encoded, causing errors with URIs that have spaces.
+
+In our testing we have found that this method shares more memory between
+RT FCGI processes, so it can allow you to run more RT processes with less
+memory. This comes at the cost of some extra management of the FCGI processes,
+which mod_fcgid handles for you.
+
 =head3 mod_perl 2.xx
 
 B<WARNING: mod_perl 1.99_xx is not supported.>
@@ -199,7 +226,7 @@ related C<ScriptAlias> and C<Location> directives with C</rt>.  You
 should also make sure C<DocumentRoot> is B<not> set to
 C</opt/rt5/share/html/>, otherwise RT's source will be served from C</>.
 
-For example: if you're using the sample FastCGI config above, you might change
+For example: if you're using the sample mod_fcgid config above, you might change
 the relevant directives to:
 
     ScriptAlias /rt /opt/rt5/sbin/rt-server.fcgi/
@@ -211,6 +238,13 @@ the relevant directives to:
         ...
     </Location>
 
+If you are using mod_proxy_fcgi, change these:
+
+    ProxyPass /rt/ unix:/opt/rt5/var/rt.sock|fcgi://localhost/
+    <Location /rt>
+        ProxyFCGISetEnvIf "true" SCRIPT_NAME "/rt"
+    </Location>
+
 If you're using the sample mod_perl configuration, you only need to change the
 C<Location> directive.
 

commit 906007d0c45206348681a6624f3ee6bcfe30cccf
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Jun 9 03:51:55 2023 +0800

    Test RT with apache+proxy_fcgi and mariadb

diff --git a/.github/workflows/github-action.yml b/.github/workflows/github-action.yml
index e7bfbad9f8..f02e48357a 100644
--- a/.github/workflows/github-action.yml
+++ b/.github/workflows/github-action.yml
@@ -57,7 +57,7 @@ jobs:
           fields: |
             [{ "title": "Configuration", "value": "RT Server, SQLite", "short": true },
             { "title": "URL", "value": "${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID}?check_suite_focus=true", "short": true }]
-  rt_test_mariadb:
+  rt_test_mariadb_apache_proxy_fcgi:
     runs-on: ubuntu-latest
     steps:
       - name: Set up for tests
@@ -80,10 +80,11 @@ jobs:
           docker run --network rt --name mariadb -e MYSQL_ROOT_PASSWORD=password -d mariadb:10.6
           docker build --network rt -t rt-base .
           docker run -d -v $GITHUB_WORKSPACE:/rt --env RT_TEST_DB_HOST=mariadb --env RT_TEST_RT_HOST=172.16.0.0/255.240.0.0 --network rt --name rt rt-base
-          docker exec rt bash -c "cd /rt && ./configure.ac --with-db-type=mysql --with-my-user-group --enable-layout=inplace --enable-developer --enable-externalauth --enable-gpg --enable-smime && mkdir -p /rt/var && make testdeps"
+          docker exec rt bash -c "chown -R rt-user /rt; touch /etc/apache2/mime.types"
+          docker exec -e USER=rt-user -u rt-user rt bash -c "cd /rt && ./configure.ac --with-db-type=mysql --with-my-user-group --enable-layout=inplace --enable-developer --enable-externalauth --enable-gpg --enable-smime && mkdir -p /rt/var && make testdeps && chmod a+rX /rt/sbin/*"
       - name: Run RT tests
         shell: bash
-        run: docker exec rt bash -c "cd /rt && RT_TEST_PARALLEL_NUM=5 make test-parallel"
+        run: docker exec -e RT_TEST_WEB_HANDLER=apache+proxy_fcgi -e HTTPD_ROOT=/etc/apache2 -e RT_TEST_APACHE=/usr/sbin/apache2 -e RT_TEST_APACHE_MODULES=/usr/lib/apache2/modules -u rt-user rt bash -c "cd /rt && RT_TEST_PARALLEL_NUM=5 make test-parallel"
       - name: Get run time
         if: always()
         shell: bash
@@ -108,7 +109,7 @@ jobs:
           failure_text: '${env.RT_BRANCH_NAME} (${env.GITHUB_RUN_NUMBER}) tests failed in ${env.RT_GA_TEST_TIME}'
           cancelled_text: '${env.RT_BRANCH_NAME} (${env.GITHUB_RUN_NUMBER}) tests cancelled in ${env.RT_GA_TEST_TIME}'
           fields: |
-            [{ "title": "Configuration", "value": "RT Server, MariaDB 10.6", "short": true },
+            [{ "title": "Configuration", "value": "Apache mod_proxy_fcgi, MariaDB 10.6", "short": true },
             { "title": "URL", "value": "${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID}?check_suite_focus=true", "short": true }]
   rt_test_mysql8:
     runs-on: ubuntu-latest

commit 50a03cabd388a251f65af541c401a7e34e568a95
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Jun 7 19:35:07 2023 +0800

    Support to run tests with apache+proxy_fcgi

diff --git a/configure.ac b/configure.ac
index 95fbdf4dfc..53e5cfada4 100755
--- a/configure.ac
+++ b/configure.ac
@@ -503,6 +503,7 @@ AC_CONFIG_FILES([
                  etc/RT_Config.pm
                  lib/RT/Generated.pm
                  t/data/configs/apache2.4+mod_perl.conf
+                 t/data/configs/apache2.4+proxy_fcgi.conf
                  t/data/configs/apache2.4+fcgid.conf],
                )
 AC_OUTPUT
diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index 78ea4aff37..003f3bc675 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -108,7 +108,7 @@ problem in Perl that hides the top-level optree from L<Devel::Cover>.
 =cut
 
 our $port;
-our @SERVERS;
+our (@SERVERS, @FCGI_SERVERS);
 my @ports; # keep track of all the random ports we used
 
 BEGIN {
@@ -1720,6 +1720,26 @@ sub start_apache_server {
     );
     push @SERVERS, $pid;
 
+    if ( $server_opt{variant} eq 'proxy_fcgi' ) {
+        local $ENV{RT_TESTING} = 1;
+        my $sock = "t/tmp/$port.sock";
+        my $fcgi_pid = RT::Test::Apache->fork_exec('sbin/rt-server.fcgi', '--listen', $sock, '--manager', '' );
+        push @FCGI_SERVERS, $fcgi_pid;
+        require IO::Socket::UNIX;
+        my $count = 0;
+        while ( $count++ < 100 ) {
+            my $client = IO::Socket::UNIX->new(
+                Type => SOCK_STREAM(),
+                Peer => $sock,
+            );
+            if ( $client && $client->connected ) {
+                $client->close;
+                last;
+            }
+            sleep 1;
+        }
+    }
+
     my $url = RT->Config->Get('WebURL');
     $url =~ s!/$!!;
     return ($url, RT::Test::Web->new);
@@ -1728,9 +1748,9 @@ sub start_apache_server {
 sub stop_server {
     my $self = shift;
     my $in_end = shift;
-    return unless @SERVERS;
+    return unless @SERVERS || @FCGI_SERVERS;
 
-    kill 'TERM', @SERVERS;
+    kill 'TERM', @SERVERS, @FCGI_SERVERS;
     foreach my $pid (@SERVERS) {
         if ($ENV{RT_TEST_WEB_HANDLER} =~ /^apache/) {
             my $count = 0;
@@ -1747,7 +1767,11 @@ sub stop_server {
         }
     }
 
-    @SERVERS = ();
+    foreach my $pid (@FCGI_SERVERS) {
+        waitpid $pid, 0;
+    }
+
+    @SERVERS = @FCGI_SERVERS = ();
 }
 
 sub temp_directory {
diff --git a/lib/RT/Test/Apache.pm b/lib/RT/Test/Apache.pm
index 2df1f7057d..c9b0306eaf 100644
--- a/lib/RT/Test/Apache.pm
+++ b/lib/RT/Test/Apache.pm
@@ -54,6 +54,7 @@ my %MODULES = (
     '2.4' => {
         "mod_perl" => [qw(mpm_worker authz_core authn_core authz_host env alias perl)],
         "fcgid"  => [qw(mpm_prefork authz_core authn_core authz_host env alias mime fcgid)],
+        "proxy_fcgi"  => [qw(mpm_event authz_core authn_core authz_host env alias mime proxy proxy_fcgi)],
     },
 );
 
@@ -121,6 +122,7 @@ sub start_server {
             || Test::More::BAIL_OUT("Couldn't figure out server root"),
         document_root  => $RT::MasonComponentRoot,
         tmp_dir        => "$tmp{'directory'}",
+        rt_base_path   => $RT::BasePath,
         rt_bin_path    => $RT::BinPath,
         rt_sbin_path   => $RT::SbinPath,
         rt_site_config => $ENV{'RT_SITE_CONFIG'},
diff --git a/t/data/configs/apache2.4+proxy_fcgi.conf.in b/t/data/configs/apache2.4+proxy_fcgi.conf.in
new file mode 100644
index 0000000000..3227143f47
--- /dev/null
+++ b/t/data/configs/apache2.4+proxy_fcgi.conf.in
@@ -0,0 +1,33 @@
+ServerRoot %%SERVER_ROOT%%
+PidFile %%PID_FILE%%
+ServerAdmin root at localhost
+
+%%LOAD_MODULES%%
+
+<IfModule !mpm_netware_module>
+<IfModule !mpm_winnt_module>
+User @WEB_USER@
+Group @WEB_GROUP@
+</IfModule>
+</IfModule>
+
+ServerName localhost
+Listen %%LISTEN%%
+
+ErrorLog "%%LOG_FILE%%"
+LogLevel debug
+
+AddDefaultCharset UTF-8
+
+ProxyPass / unix:%%RT_BASE_PATH%%/t/tmp/%%LISTEN%%.sock|fcgi://localhost/
+ProxyFCGIBackendType GENERIC
+ProxyFCGISetEnvIf "true" SCRIPT_NAME ""
+
+DocumentRoot "%%DOCUMENT_ROOT%%"
+<Location />
+
+    <RequireAll>
+        Require all granted
+%%BASIC_AUTH%%
+    </RequireAll>
+</Location>

commit de7f2ff04be30725db3ea1d07d8acaed6fb44f3d
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Jun 7 19:08:54 2023 +0800

    Drop obsolete apache and fastcgi test configs

diff --git a/configure.ac b/configure.ac
index acae97c8b1..95fbdf4dfc 100755
--- a/configure.ac
+++ b/configure.ac
@@ -502,10 +502,7 @@ AC_CONFIG_FILES([
                  Makefile
                  etc/RT_Config.pm
                  lib/RT/Generated.pm
-                 t/data/configs/apache2.2+mod_perl.conf
-                 t/data/configs/apache2.2+fastcgi.conf
                  t/data/configs/apache2.4+mod_perl.conf
-                 t/data/configs/apache2.4+fastcgi.conf
                  t/data/configs/apache2.4+fcgid.conf],
                )
 AC_OUTPUT
diff --git a/lib/RT/Test/Apache.pm b/lib/RT/Test/Apache.pm
index 8b75aaf71d..2df1f7057d 100644
--- a/lib/RT/Test/Apache.pm
+++ b/lib/RT/Test/Apache.pm
@@ -51,13 +51,8 @@ use strict;
 use warnings;
 
 my %MODULES = (
-    '2.2' => {
-        "mod_perl" => [qw(authz_host env alias perl)],
-        "fastcgi"  => [qw(authz_host env alias mime fastcgi)],
-    },
     '2.4' => {
         "mod_perl" => [qw(mpm_worker authz_core authn_core authz_host env alias perl)],
-        "fastcgi"  => [qw(mpm_worker authz_core authn_core authz_host env alias mime fastcgi)],
         "fcgid"  => [qw(mpm_prefork authz_core authn_core authz_host env alias mime fcgid)],
     },
 );
diff --git a/t/data/configs/apache2.2+fastcgi.conf.in b/t/data/configs/apache2.2+fastcgi.conf.in
deleted file mode 100644
index 329b0561eb..0000000000
--- a/t/data/configs/apache2.2+fastcgi.conf.in
+++ /dev/null
@@ -1,49 +0,0 @@
-ServerRoot %%SERVER_ROOT%%
-PidFile %%PID_FILE%%
-LockFile %%LOCK_FILE%%
-ServerAdmin root at localhost
-
-%%LOAD_MODULES%%
-
-<IfModule !mpm_netware_module>
-<IfModule !mpm_winnt_module>
-User @WEB_USER@
-Group @WEB_GROUP@
-</IfModule>
-</IfModule>
-
-ServerName localhost
-Listen %%LISTEN%%
-
-ErrorLog "%%LOG_FILE%%"
-LogLevel debug
-
-<Directory />
-    Options FollowSymLinks
-    AllowOverride None
-    Order deny,allow
-    Deny from all
-</Directory>
-
-AddDefaultCharset UTF-8
-
-FastCgiServer %%RT_SBIN_PATH%%/rt-server.fcgi \
-    -socket %%TMP_DIR%%/socket \
-    -processes 1 \
-    -idle-timeout 180 \
-    -initial-env RT_SITE_CONFIG=%%RT_SITE_CONFIG%% \
-    -initial-env RT_TESTING=1
-
-ScriptAlias / %%RT_SBIN_PATH%%/rt-server.fcgi/
-
-DocumentRoot "%%DOCUMENT_ROOT%%"
-<Location />
-    Order allow,deny
-    Allow from all
-
-%%BASIC_AUTH%%
-
-    Options +ExecCGI
-    AddHandler fastcgi-script fcgi
-</Location>
-
diff --git a/t/data/configs/apache2.2+mod_perl.conf.in b/t/data/configs/apache2.2+mod_perl.conf.in
deleted file mode 100644
index 20d2f44e52..0000000000
--- a/t/data/configs/apache2.2+mod_perl.conf.in
+++ /dev/null
@@ -1,67 +0,0 @@
-<IfModule mpm_prefork_module>
-    StartServers          1
-    MinSpareServers       1
-    MaxSpareServers       1
-    MaxClients            1
-    MaxRequestsPerChild   0
-</IfModule>
-
-<IfModule mpm_worker_module>
-    StartServers          1
-    MinSpareThreads       1
-    MaxSpareThreads       1
-    ThreadLimit           1
-    ThreadsPerChild       1
-    MaxClients            1
-    MaxRequestsPerChild   0
-</IfModule>
-
-ServerRoot %%SERVER_ROOT%%
-PidFile %%PID_FILE%%
-LockFile %%LOCK_FILE%%
-ServerAdmin root at localhost
-
-%%LOAD_MODULES%%
-
-<IfModule !mpm_netware_module>
-<IfModule !mpm_winnt_module>
-User @WEB_USER@
-Group @WEB_GROUP@
-</IfModule>
-</IfModule>
-
-ServerName localhost
-Listen %%LISTEN%%
-
-ErrorLog "%%LOG_FILE%%"
-LogLevel debug
-
-<Directory />
-    Options FollowSymLinks
-    AllowOverride None
-    Order deny,allow
-    Deny from all
-</Directory>
-
-AddDefaultCharset UTF-8
-PerlSetEnv RT_SITE_CONFIG %%RT_SITE_CONFIG%%
-
-DocumentRoot "%%DOCUMENT_ROOT%%"
-<Location />
-    Order allow,deny
-    Allow from all
-
-%%BASIC_AUTH%%
-
-    SetHandler modperl
-
-    PerlResponseHandler Plack::Handler::Apache2
-    PerlSetVar psgi_app %%RT_SBIN_PATH%%/rt-server
-</Location>
-
-<Perl>
-    $ENV{RT_TESTING}=1;
-    use Plack::Handler::Apache2;
-    Plack::Handler::Apache2->preload("%%RT_SBIN_PATH%%/rt-server");
-</Perl>
-
diff --git a/t/data/configs/apache2.4+fastcgi.conf.in b/t/data/configs/apache2.4+fastcgi.conf.in
deleted file mode 100644
index 665ddc4796..0000000000
--- a/t/data/configs/apache2.4+fastcgi.conf.in
+++ /dev/null
@@ -1,48 +0,0 @@
-ServerRoot %%SERVER_ROOT%%
-PidFile %%PID_FILE%%
-ServerAdmin root at localhost
-
-%%LOAD_MODULES%%
-
-<IfModule !mpm_netware_module>
-<IfModule !mpm_winnt_module>
-User @WEB_USER@
-Group @WEB_GROUP@
-</IfModule>
-</IfModule>
-
-ServerName localhost
-Listen %%LISTEN%%
-
-ErrorLog "%%LOG_FILE%%"
-LogLevel debug
-
-<Directory />
-    Options FollowSymLinks
-    AllowOverride None
-    Require all denied
-</Directory>
-
-AddDefaultCharset UTF-8
-
-FastCgiServer %%RT_SBIN_PATH%%/rt-server.fcgi \
-    -socket %%TMP_DIR%%/socket \
-    -processes 1 \
-    -idle-timeout 180 \
-    -initial-env RT_SITE_CONFIG=%%RT_SITE_CONFIG%% \
-    -initial-env RT_TESTING=1
-
-ScriptAlias / %%RT_SBIN_PATH%%/rt-server.fcgi/
-
-DocumentRoot "%%DOCUMENT_ROOT%%"
-<Location />
-
-    <RequireAll>
-        Require all granted
-%%BASIC_AUTH%%
-    </RequireAll>
-
-    Options +ExecCGI
-    AddHandler fastcgi-script fcgi
-</Location>
-

-----------------------------------------------------------------------


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list