enhancing codepot/config/config.php to sense X-Fowarded-Host
This commit is contained in:
parent
14c5679f89
commit
893b4a4159
@ -16,4 +16,7 @@ RUN dnf install -y php-devel subversion-devel perl-devel make
|
||||
COPY build-rocky84.sh /tmp
|
||||
RUN /tmp/build-rocky84.sh && rm -rf /tmp/*
|
||||
|
||||
CMD ["/usr/sbin/httpd-fg.sh"]
|
||||
COPY httpd-fg.sh /usr/sbin/
|
||||
|
||||
##CMD ["/usr/sbin/httpd-fg.sh"]
|
||||
ENTRYPOINT ["/usr/sbin/httpd-fg.sh"]
|
||||
|
@ -12,4 +12,6 @@ RUN apt update && \
|
||||
COPY build-ubnt2004.sh /tmp
|
||||
RUN /tmp/build-ubnt2004.sh && rm -rf /tmp/*
|
||||
|
||||
COPY apache2-fg.sh /usr/sbin/
|
||||
|
||||
CMD ["/usr/sbin/apache2-fg.sh"]
|
||||
|
@ -15,7 +15,6 @@ cd codepot && \
|
||||
--with-cachedir=/var/cache/codepot \
|
||||
--with-phpextdir=`php-config --extension-dir` \
|
||||
make && make install && \
|
||||
install -m 0755 -D -t /usr/sbin docker/httpd-fg.sh && \
|
||||
cd ../.. && \
|
||||
rm -rf /var/lib/codepot/* && \
|
||||
sed -ri -e 's|^database_hostname[[:space:]]*=[[:space:]]*"localhost"$|database_hostname = "/var/lib/codepot/codepot.db"|g' \
|
||||
|
@ -14,7 +14,6 @@ cd codepot && \
|
||||
--with-phpextdir=`php-config --extension-dir` \
|
||||
--with-phpextinidir=`php-config --ini-dir | sed 's|/cli/|/apache2/|g'` && \
|
||||
make && make install && \
|
||||
install -m 0755 -D -t /usr/sbin docker/apache2-fg.sh && \
|
||||
cd ../.. && \
|
||||
rm -rf /var/lib/codepot/* && \
|
||||
sed -ri -e 's|^database_hostname[[:space:]]*=[[:space:]]*"localhost"$|database_hostname = "/var/lib/codepot/codepot.db"|g' \
|
||||
|
@ -1,6 +1,52 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
SERVICE_PORT=""
|
||||
while getopts ":hp:-:" oc
|
||||
do
|
||||
case "${oc}" in
|
||||
-)
|
||||
case "${OPTARG}" in
|
||||
port)
|
||||
opt=${OPTARG}
|
||||
SERVICE_PORT="${!OPTIND}"
|
||||
OPTIND=$(($OPTIND + 1))
|
||||
;;
|
||||
port=*)
|
||||
SERVICE_PORT=${OPTARG#*=}
|
||||
opt=${OPTARG%=$val}
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Warning: unknown option - $OPTARG"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
h)
|
||||
echo "-----------------------------------------------------------"
|
||||
echo "This container runs a http service on port 80."
|
||||
echo "Use an external reverse proxy to enable https as it doesn't"
|
||||
echo "enable the HTTP service."
|
||||
echo "Extra options allowed when running the container: "
|
||||
echo " -h print this help message"
|
||||
echo " -p number specify the port number"
|
||||
echo " -port number specify the port number"
|
||||
echo "-----------------------------------------------------------"
|
||||
;;
|
||||
p)
|
||||
SERVICE_PORT=${OPTARG#*=}
|
||||
opt=${OPTARG%=$val}
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Warning: unknown option - $OPTARG"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
echo "${SERVICE_PORT}" | grep -q -E '^[[:digit:]]+$' || SERVICE_PORT="80"
|
||||
|
||||
|
||||
# Note: we don't just use "apache2ctl" here because it itself is just a shell-script wrapper around apache2 which provides extra functionality like "apache2ctl start" for launching apache2 in the background.
|
||||
# (also, when run as "apache2ctl <apache args>", it does not use "exec", which leaves an undesirable resident shell process)
|
||||
|
||||
@ -54,5 +100,9 @@ grep -F -q 'env[CODEPOT_CONFIG_FILE]' /etc/php-fpm.d/www.conf || {
|
||||
echo 'env[CODEPOT_CONFIG_FILE] = /var/lib/codepot/codepot.ini' >> /etc/php-fpm.d/www.conf
|
||||
}
|
||||
|
||||
## change the port number as specified on the command line
|
||||
echo "Configuring to listen on the port [$SERVICE_PORT]"
|
||||
sed -r -i "s|^Listen[[:space:]]+.*|Listen ${SERVICE_PORT}|g" /etc/httpd/conf/httpd.conf
|
||||
|
||||
php-fpm
|
||||
exec httpd -DFOREGROUND "$@"
|
||||
exec httpd -DFOREGROUND
|
||||
|
@ -38,6 +38,11 @@ else
|
||||
$_SERVER['REQUEST_PROTOCOL'] = 'http';
|
||||
}
|
||||
|
||||
if (array_key_exists('HTTP_X_FORWARDED_HOST', $_SERVER) && $_SERVER['HTTP_X_FORWARDED_HOST'] != '')
|
||||
{
|
||||
$_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
|
||||
}
|
||||
|
||||
$config['base_url'] .= "://{$_SERVER['HTTP_HOST']}";
|
||||
$config['base_url'] .= preg_replace('@/+$@','',dirname($_SERVER['SCRIPT_NAME'])).'/';
|
||||
|
||||
|
@ -2217,25 +2217,8 @@ class SubversionModel extends CodeRepoModel
|
||||
|
||||
foreach ($hooks as $hook)
|
||||
{
|
||||
// copy hook scripts to the top repository directory
|
||||
// overwriting existing scripts are ok as they are
|
||||
// just updated to the latest scripts anyway.
|
||||
$contents = @file_get_contents("{$cfgdir}/${hook}");
|
||||
if ($contents === FALSE)
|
||||
{
|
||||
self::_deleteDirectory ($projdir);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (@file_put_contents("{$repodir}/${hook}", str_replace('%API%', $api, $contents)) === FALSE)
|
||||
{
|
||||
self::_deleteDirectory ($projdir);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// install the hook script to the new project repository
|
||||
if (@chmod("{$repodir}/{$hook}", 0755) === FALSE ||
|
||||
@symlink("../../{$hook}", "{$repodir}/{$projectid}/hooks/${hook}") === FALSE)
|
||||
// install the hook script to the new project repository using symbolic links
|
||||
if (@symlink("${cfgdir}/${hook}", "{$repodir}/{$projectid}/hooks/${hook}") === FALSE)
|
||||
{
|
||||
self::_deleteDirectory ($projdir);
|
||||
return FALSE;
|
||||
|
Loading…
Reference in New Issue
Block a user