From c6b3d45a1bb905a79aef07c2ecfde57e5446a08c Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 24 May 2017 16:00:09 -0400 Subject: [PATCH] LP#1691473 Internal Apache HTTP port configuration Adds an optional new Apache/mod_perl configuration variable for defining the port Apache listens on for HTTP traffic. This resolves an issue where added content lookups attempting HTTP requests on the local Apache instance on port 80 failed because Apache was using non-standard ports. To test: [1] Set a value for OILSWebInternalHTTPPort that's not "80". [2] Restart/reload Apache [3] Load a record detail in the catalog [4] Confirm opensrf logs show: "tpac: added content connecting to : / should be the value configured for OILSWebInternalHTTPPort. Signed-off-by: Bill Erickson Signed-off-by: Galen Charlton --- Open-ILS/examples/apache/eg_vhost.conf.in | 6 ++++++ Open-ILS/examples/apache_24/eg_vhost.conf.in | 6 ++++++ .../src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm | 11 ++++++++--- .../Administration/apache-internal-http-port.adoc | 16 ++++++++++++++++ 4 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 docs/RELEASE_NOTES_NEXT/Administration/apache-internal-http-port.adoc diff --git a/Open-ILS/examples/apache/eg_vhost.conf.in b/Open-ILS/examples/apache/eg_vhost.conf.in index a41382139a..bec5af162c 100644 --- a/Open-ILS/examples/apache/eg_vhost.conf.in +++ b/Open-ILS/examples/apache/eg_vhost.conf.in @@ -628,6 +628,12 @@ RewriteRule ^/openurl$ ${openurl:%1} [NE,PT] PerlSetVar OILSWebWebDir "@localstatedir@/web" PerlSetVar OILSWebDefaultTemplateExtension "tt2" + # Port Apache listens on for HTTP traffic. Used for HTTP requests + # routed from Perl handlers back to the same Apache instance, like + # added content requests. Use this when running Apache with a + # non-standard port, typical with a proxy setup. Defaults to "80". + # PerlSetVar OILSWebInternalHTTPPort "7080" + # Enable Template-Toolkit error debugging messages (apache error log) PerlSetVar OILSWebDebugTemplate "false" # local cache of compiled Template Toolkit templates diff --git a/Open-ILS/examples/apache_24/eg_vhost.conf.in b/Open-ILS/examples/apache_24/eg_vhost.conf.in index 5821c28cb5..11fc752fc2 100644 --- a/Open-ILS/examples/apache_24/eg_vhost.conf.in +++ b/Open-ILS/examples/apache_24/eg_vhost.conf.in @@ -618,6 +618,12 @@ RewriteRule ^/openurl$ ${openurl:%1} [NE,PT] PerlSetVar OILSWebWebDir "@localstatedir@/web" PerlSetVar OILSWebDefaultTemplateExtension "tt2" + # Port Apache listens on for HTTP traffic. Used for HTTP requests + # routed from Perl handlers back to the same Apache instance, like + # added content requests. Use this when running Apache with a + # non-standard port, typical with a proxy setup. Defaults to "80". + # PerlSetVar OILSWebInternalHTTPPort "7080" + # Enable Template-Toolkit error debugging messages (apache error log) PerlSetVar OILSWebDebugTemplate "false" # local cache of compiled Template Toolkit templates diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm index 98aef3c272..114de0cb69 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm @@ -537,10 +537,14 @@ sub added_content_stage1 { # This avoids us having to route out of the cluster # and back in to reach the top-level virtualhost. my $ac_addr = $ENV{SERVER_ADDR}; + # Internal connections are HTTP-only (no HTTPS) and assume the + # connection port is '80' unless otherwise specified in the Apache + # configuration (e.g. for proxy setups) + my $ac_port = $self->apache->dir_config('OILSWebInternalHTTPPort') || 80; my $ac_host = $self->apache->hostname; my $ac_failed = 0; - $logger->info("tpac: added content connecting to $ac_addr / $ac_host"); + $logger->info("tpac: added content connecting to $ac_addr:$ac_port / $ac_host"); $ctx->{added_content} = {}; for my $type (@$ac_types) { @@ -556,9 +560,10 @@ sub added_content_stage1 { # Connecting to oneself should either be very fast (normal) # or very slow (routing problems). - my $req = Net::HTTP::NB->new(Host => $ac_addr, Timeout => 1); + my $req = Net::HTTP::NB->new( + Host => $ac_addr, Timeout => 1, PeerPort => $ac_port); if (!$req) { - $logger->warn("Unable to connect to $ac_addr / $ac_host". + $logger->warn("Unable to connect to $ac_addr:$ac_port / $ac_host". " for added content lookup for $rec_id: $@"); $ac_failed = 1; next; diff --git a/docs/RELEASE_NOTES_NEXT/Administration/apache-internal-http-port.adoc b/docs/RELEASE_NOTES_NEXT/Administration/apache-internal-http-port.adoc new file mode 100644 index 0000000000..9d61d58b9c --- /dev/null +++ b/docs/RELEASE_NOTES_NEXT/Administration/apache-internal-http-port.adoc @@ -0,0 +1,16 @@ +Apache Internal Port Configuration Option +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Apache configuration now supports a new variable which allows admins to +specify the port used by Apache to handle HTTP traffic. The value is +used for HTTP requests routed from Perl handlers back to the same Apache +instance, like added content requests. Use this when running Apache +with a non-standard port, typical with a proxy setup. Defaults to "80". + +[source,conf] +------------------------------------------------------------------- + + ... + PerlSetVar OILSWebInternalHTTPPort "7080" + ... + +------------------------------------------------------------------- -- 2.11.0