Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Varnish pass client ip?

    Scheduled Pinned Locked Moved pfSense Packages
    9 Posts 2 Posters 3.6k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      josh4trunks
      last edited by

      Hey guys I've been using pfsense 2.0 for a few monthes now and been loving it, currently on 2.0.1 and have the varnish package working well, I just can't get one feature of varnish working as expected.

      When I used to have varnish on my ubuntu box I used the lines below to pass the original ip to my apache server on another ubuntu box and it worked great (I got a module for apache that accepts ip). But the same 2 lines doesn't seem to work now on my pfsense box. My ubuntu webserver backend see's all requests comming from 192.168.1.1, when I try everything through varnish on my ubuntu box again it seems to work as expected and expternal ip's are seen.

      sub vcl_recv {
        remove req.http.X-Forwarded-For;
        set req.http.X-Forwarded-For = client.ip;
      }
      

      Not sure what's going on and if maybe the varnish version on pfsense works a bit differently, thanks for the help!

      1 Reply Last reply Reply Quote 0
      • marcellocM
        marcelloc
        last edited by

        It works to me, check these settings on your varnish package and then on configuration files.

        varnish.png
        varnish.png_thumb

        Treinamentos de Elite: http://sys-squad.com

        Help a community developer! ;D

        1 Reply Last reply Reply Quote 0
        • J
          josh4trunks
          last edited by

          tried that, it adds
          "set req.http.X-Forwarded-Varnish = client.ip;"
          to the vcl, but my backend still says all requests come from 192.168.1.1, when I passthrough varnish on my ubuntu box it works fine

          1 Reply Last reply Reply Quote 0
          • marcellocM
            marcelloc
            last edited by

            Change forward var name to x-Forwarded-for.

            I've created this x-forwarded-varnish to be sure I was reading the right value

            Treinamentos de Elite: http://sys-squad.com

            Help a community developer! ;D

            1 Reply Last reply Reply Quote 0
            • J
              josh4trunks
              last edited by

              I've definitely tried x-forwarded-for option as well, I've also tried a custom config with the same options i use for varnish on my ubuntu box (I use x-forwarded-for there). Neither seem to pass the ip, maybe the nat port forwarding is doing something funny? I'm running varnish on pfsense's port 8080, and forwarding that to wan on port 80. I doubt it but i can't rule out anything at this point…

              1 Reply Last reply Reply Quote 0
              • marcellocM
                marcelloc
                last edited by

                You cannot setup a port forward on same port varnish is listening on.

                Disable this nat and be sure you have a wan rule to permit traffic on varnish listening port.

                Treinamentos de Elite: http://sys-squad.com

                Help a community developer! ;D

                1 Reply Last reply Reply Quote 0
                • J
                  josh4trunks
                  last edited by

                  I didn't configure apache to allow x-forwardedip's from 192.168.1.1, lol only from my old ubuntu varnish server's ip. Well I guess I'm an idiot and this thread can be closed

                  1 Reply Last reply Reply Quote 0
                  • marcellocM
                    marcelloc
                    last edited by

                    ok, never mind.  ;)

                    Just to know. Are you using 3.x or 2.x varnish version?

                    Treinamentos de Elite: http://sys-squad.com

                    Help a community developer! ;D

                    1 Reply Last reply Reply Quote 0
                    • J
                      josh4trunks
                      last edited by

                      2.X don't need streaming support, still trying to learn how to put together a decent static website, lol

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post
                      Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.