<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p><font face="Tahoma">Hello there ;)</font></p>
<p>I'm running varnish in front of my apache on port 80 without any
issues so far.<br>
<br>
Recently I decided to also use varnish for SSL connections<br>
<br>
To do so I first do a http to https redirect within varnish VCL<br>
<br>
if ( req.http.X-Forwarded-Proto !~ "(?i)https" ) {<br>
return (synth(750, ""));<br>
}<br>
<br>
then in vcl_synth()<br>
<br>
sub vcl_synth {<br>
<br>
if (resp.status == 750) {<br>
set resp.status = 301;<br>
set resp.http.Location = <a class="moz-txt-link-rfc2396E" href="https://">"https://"</a> +
req.http.host + req.url;<br>
return(deliver);<br>
}<br>
}<br>
<br>
This works fine and all http got redirected to https<br>
<br>
Then on port 443 I got apache listening as a reverse proxy with
the following config:<br>
<br>
<VirtualHost *:443><br>
<br>
ServerName somedomain.com<br>
ServerAlias *.somedomain.org<br>
<br>
SSLEngine on</p>
<p> ... ssl cert stuff here ...<br>
</p>
ProxyPreserveHost On<br>
ProxyPass / <a class="moz-txt-link-freetext" href="http://127.0.0.1:80/">http://127.0.0.1:80/</a><br>
ProxyPassReverse / <a class="moz-txt-link-freetext" href="http://127.0.0.1:80/">http://127.0.0.1:80/</a><br>
RequestHeader set X-Forwarded-Port "443"<br>
RequestHeader set X-Forwarded-Proto "https"<br>
<p></VirtualHost><br>
<br>
Also this works perfectly fine! Apache does the SSL termination
and then reverse proxies everything back to varnish on port 80<br>
<br>
If I have a look in the apache ssl log:<br>
<br>
[15/Aug/2017:02:03:41 +0200] 35.190.201.122 TLSv1.2
ECDHE-RSA-AES128-GCM-SHA256 "GET /feed/ HTTP/1.1" -
<a class="moz-txt-link-rfc2396E" href="http://domain.org/feed/">"http://domain.org/feed/"</a> "Go-http-client/1.1"<br>
[15/Aug/2017:02:03:41 +0200] 35.190.201.122 TLSv1.2
ECDHE-RSA-AES128-GCM-SHA256 "GET /feed HTTP/1.1" 10513
<a class="moz-txt-link-rfc2396E" href="https://domain.org/feed/">"https://domain.org/feed/"</a> "Go-http-client/1.1"<br>
<br>
If I look in the varnishlog I see the following:<br>
<br>
domain.org 35.190.201.122 - - [15/Aug/2017:02:03:41 +0200] "GET
<a class="moz-txt-link-freetext" href="http://domain.org/feed/">http://domain.org/feed/</a> HTTP/1.1" 301 0 "-" "Go-http-client/1.1"<br>
domain.org 127.0.0.1 - - [15/Aug/2017:02:03:41 +0200] "GET
<a class="moz-txt-link-freetext" href="http://domain.org/feed/">http://domain.org/feed/</a> HTTP/1.1" 301 0 <a class="moz-txt-link-rfc2396E" href="http://domain.org/feed/">"http://domain.org/feed/"</a>
"Go-http-client/1.1"<br>
domain.org 127.0.0.1 - - [15/Aug/2017:02:03:41 +0200] "GET
<a class="moz-txt-link-freetext" href="http://domain.org/feed">http://domain.org/feed</a> HTTP/1.1" 200 10513
<a class="moz-txt-link-rfc2396E" href="https://domain.org/feed/">"https://domain.org/feed/"</a> "Go-http-client/1.1"<br>
<br>
But in the process of Varnish -> Redirect http to https ->
Apache Reverse Proxy -> Varnish I loose the client IP address
in varnishlog<br>
It jsut says 127.0.0.1<br>
<br>
How can I forward the client IP to varnishlog in this process?<br>
<br>
I need to have the client IP in varnishlog as I use those to
generate statistics about the website.<br>
<br>
any help, hints or insights would be awesome ;)<br>
<br>
Thanks & greetings<br>
Becki<br>
<br>
<br>
</p>
<pre class="moz-signature" cols="72">--
Beckspaced - Server Administration
------------------------------------------------
Ralf Flederer
Marienplatz 9
97353 Wiesentheid
Tel.: 09383-9033825
Mobil: 01577-7258912
Internet: <a class="moz-txt-link-abbreviated" href="http://www.beckspaced.com">www.beckspaced.com</a>
------------------------------------------------</pre>
</body>
</html>