Skip to content

Commit

Permalink
Releasing version 2016.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurcf committed Jun 13, 2016
1 parent 8adef61 commit 340fa0a
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 4 deletions.
20 changes: 20 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
* Jun 01 2016 CloudFlare Inc <[email protected]> - 2016.6.0
- Set HTTPS envrionment variable for Flexible SSL reqquests

* May 16 2016 CloudFlare Inc <[email protected]> - 2016.5.1
- Update CloudFlare IP ranges
- Add EasyApache support
- Update versioning scheme

* Jul 07 2015 CloudFlare Inc <[email protected]> - 1.3.1
- Update CloudFlare IP ranges

* Apr 15 2014 CloudFlare Inc <[email protected]> - 1.3.0
- Enable IPv6 support

* Mar 20 2013 CloudFlare Inc <[email protected]> - 1.2.0
- Refactor for Apache 2.4, utilize autotools for RPM/DEB builds

* Aug 30 2012 CloudFlare Inc <[email protected]> - 1.1.2
- Bugfix for intermittent segfaults under some conditions.
- Pulled from remoteip codebase.
46 changes: 46 additions & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
srcdir = @srcdir@

DESTDIR =
LIBEXECDIR = @LIBEXECDIR@

CPPFLAGS = @CPPFLAGS@
CFLAGS = @CFLAGS@
LDFLAGS = @LDFLAGS@
LDLIBS = @LDLIBS@

APXS = @APXS@

all : mod_cloudflare.la

mod_cloudflare.la : mod_cloudflare.c
$(APXS) -c $(CPPFLAGS) $(CFLAGS) $(srcdir)/mod_cloudflare.c $(LDFLAGS) $(LDLIBS)

$(DESTDIR)$(LIBEXECDIR) :
mkdir -p $@

install : all $(DESTDIR)$(LIBEXECDIR)
$(APXS) -i -S LIBEXECDIR=$(DESTDIR)$(LIBEXECDIR) -n 'mod_cloudflare' $(srcdir)/mod_cloudflare.la

clean :
-rm -f $(srcdir)/.libs/*
-rm -f $(srcdir)/*.o
-rm -f $(srcdir)/*.lo
-rm -f $(srcdir)/*.la
-rm -f $(srcdir)/*.slo
-rm -rf $(srcdir)/.libs
-rm -rf autom4te.cache
-rm -f config.log config.status

distclean : clean
-rm -f Makefile

gitclean : distclean
-rm -f configure src-package.tar.gz

src-package:
@tar cz *.c configure.ac Makefile.in LICENSE ChangeLog README VERSION > $@.tar.gz

$(srcdir)/configure: configure.ac
cd '$(srcdir)' && autoconf && ./configure

Makefile: Makefile.in configure
22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
# mod_cloudflare for Apache #
Copyright CloudFlare Inc. 2013
Copyright CloudFlare Inc. 2016

## mod_cloudflare.c ##

Based on mod_remoteip.c, this Apache extension will replace the remote_ip variable in user's logs with the correct remote IP sent from CloudFlare. The module only performs the IP substitution for requests originating from CloudFlare IPs by default.

To install, follow the instructions on:
https://www.cloudflare.com/resources-downloads#mod_cloudflare

In addition to this, the extension will also set the HTTPS environment variable to "on" in cases where Flexible SSL is in use. This prevents software such as WordPress from being broken by Flexible SSL.

To install, either run apxs2 directly against the .c source file:

$ apxs2 -a -i -c mod_cloudflare.c

An alternative way to install is to use GNU autotools, which requires that autoconf and automake already be installed:

$ autoconf
$ ./configure
$ make
$ make install

No further configuration is needed. However, if you wish to override the default values, the following directives are exposed:

### CloudFlareRemoteIPHeader ###
Expand All @@ -26,6 +36,10 @@ Note that on some systems, you may have to add a `LoadModule` directive manually

Replace `/usr/lib/apache2/modules/mod_cloudflare.so` with the path to `mod_cloudflare.so` on your system.

If you cannot find `apxs` or `apxs2`, install `apache2-dev` on Debian and Ubuntu, or `httpd-devel` on Red Hat and CentOS:

$ apt-get install apache2-dev
$ yum install httpd-devel

NOTES:

Expand Down
3 changes: 3 additions & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MAJOR=2016
MINOR=6
BUILD=0
58 changes: 58 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
dnl Process this file with autoconf to produce a configure script.

AC_INIT(mod_cloudflare, m4_esyscmd([ ( VERSFILE="./VERSION"; if [ -d .git -a -x "$(which git)" -a -n "$(git describe --tags --always --dirty=-dev 2> /dev/null)" ]; then echo "$(git describe --tags --always --dirty=-dev 2> /dev/null )"; else if [ -f "$VERSFILE" ]; then . "$VERSFILE"; echo "${MAJOR}.${MINOR}.${BUILD}"; else echo "0.0.0"; fi; fi ) | tr -d '\n' ]))
AC_CONFIG_SRCDIR([mod_cloudflare.c])
AC_PREREQ([2.53])

AC_CHECK_FUNCS([strrchr])

AC_ARG_WITH(apxs, AC_HELP_STRING([--with-apxs=NAME],
[name of the apxs executable [[apxs]]]),
[APXS="$with_apxs"])

if test -z "${APXS}"; then
AC_PATH_PROGS(APXS, apxs2 apxs, [apxs],
[$PATH:/usr/local/apache/bin:/usr/sbin])
fi

AC_SUBST(APXS)

AC_MSG_CHECKING(Apache version)
HTTPD="`${APXS} -q SBINDIR`/`${APXS} -q TARGET`"
HTTPD_INCLUDEDIR="`${APXS} -q INCLUDEDIR`"
if test -x ${HTTPD}; then
HTTPD_VERSION=`${HTTPD} -v | awk '/version/ {print $3}' \
| awk -F/ '{print $2}'`
else
if test -f ${HTTPD_INCLUDEDIR}/ap_release.h; then
HTTPD_VERSION=`grep '^#define AP_SERVER_MAJORVERSION_NUMBER ' \
${HTTPD_INCLUDEDIR}/ap_release.h | sed -e \
's/^#define AP_SERVER_MAJORVERSION_NUMBER \([0-9]\).*/\1.X/'`
else
if test -f ${HTTPD_INCLUDEDIR}/httpd.h; then
HTTPD_VERSION=`grep '^#define APACHE_RELEASE ' \
${HTTPD_INCLUDEDIR}/httpd.h | sed -e \
's/^#define APACHE_RELEASE \([0-9]\).*/\1.X/'`
else
HTTPD_VERSION="2.?"
fi
fi
fi
AC_MSG_RESULT($HTTPD_VERSION)

CPPFLAGS="${CPPFLAGS}"
CFLAGS=""
LDFLAGS="${LDFLAGS}"
LDLIBS="${LDLIBS}"

AC_SUBST(CPPFLAGS)
AC_SUBST(CFLAGS)
AC_SUBST(LDFLAGS)
AC_SUBST(LDLIBS)

LIBEXECDIR="`${APXS} -q LIBEXECDIR`"
AC_SUBST(LIBEXECDIR)

HTTPD_MAJOR_VERSION=`echo ${HTTPD_VERSION} | sed -e 's/\..*//'`

AC_OUTPUT([Makefile])
9 changes: 9 additions & 0 deletions mod_cloudflare.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,18 @@ static int cloudflare_modify_connection(request_rec *r)
char *eos;
unsigned char *addrbyte;
void *internal = NULL;
const char *cf_visitor_header = NULL;

apr_pool_userdata_get((void*)&conn, "mod_cloudflare-conn", c->pool);

cf_visitor_header = apr_table_get(r->headers_in, "CF-Visitor");
if (cf_visitor_header != NULL) {
if ((remote) && (strstr(cf_visitor_header, "https") != NULL)) {
apr_table_t *e = r->subprocess_env;
apr_table_addn(e, "HTTPS", "on");
}
}

if (conn) {
if (remote && (strcmp(remote, conn->prior_remote) == 0)) {
/* TODO: Recycle r-> overrides from previous request
Expand Down

0 comments on commit 340fa0a

Please sign in to comment.