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

    Host header forwarding

    Scheduled Pinned Locked Moved Firewalling
    32 Posts 3 Posters 15.8k 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.
    • marcellocM
      marcelloc
      last edited by

        if (req.http.host == "www.mydomain.com") {
            set req.backend = WebsiteBACKEND;
         } 
            else if (req.http.host == "user.domain2.com") {
            set req.backend = WHSBACKEND;
         } 
            else if (req.http.host == "mail.mydomain.com/owa") {
            set req.backend = ExchangeBACKEND;
         } 
      

      move more specific redirect to the first backend config

      it should looks like this:

        if (req.http.host == "mail.mydomain.com/owa") {
            set req.backend = ExchangeBACKEND;
         } 
            else if (req.http.host == "user.domain2.com") {
            set req.backend = WHSBACKEND;
         } 
            else if (req.http.host == "www.mydomain.com") {
            set req.backend = WebsiteBACKEND;
         } 
      

      also, paste here the return from
      /usr/local/etc/rc.d/varnish.sh start

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

      Help a community developer! ;D

      1 Reply Last reply Reply Quote 0
      • B
        baron164
        last edited by

        Where should I run /usr/local/etc/rc.d/varnish.sh start ? If I SSH into the box and go to option 8 (Shell) it won't let me. If I got to the developer shell then I can enter the command and nothing happens.

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

          it should return this:

          /usr/local/etc/rc.d/varnish.sh start

          
          kern.ipc.nmbclusters: 65536
          sysctl: kern.ipc.nmbclusters: Invalid argument
          kern.ipc.somaxconn: 16384 -> 16384
          kern.maxfiles: 131072 -> 131072
          kern.maxfilesperproc: 104856 -> 104856
          kern.threads.max_threads_per_proc: 4096 -> 4096
          storage_malloc: max size 2048 MB.
          Using old SHMFILE
          
          

          If you get any erros, it will show too.

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

          Help a community developer! ;D

          1 Reply Last reply Reply Quote 0
          • B
            baron164
            last edited by

            I was able to run the stop/start command finally.

            It gives me the following:

            kern.ipc.nmbclusters: 65536
            sysctl: kern.ipc.nmbclusters: Invalid argument
            kern.ipc.somaxconn: 16384 -> 16384
            kern.maxfiles: 131072 -> 131072
            kern.maxfilesperproc: 104856 -> 104856
            kern.threads.max_threads_per_proc: 4096 -> 4096
            storage_malloc: max size 512 MB.
            Using old SHMFILE

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

              So, It's running.

              Go on dashboard, add varnish widget to see backend status

              they may look like this:

              varnish_widget.png
              varnish_widget.png_thumb

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

              Help a community developer! ;D

              1 Reply Last reply Reply Quote 0
              • B
                baron164
                last edited by

                Varnish is not among the list of widgets to add.

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

                  What varnish package version are you using?   :o ???

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

                  Help a community developer! ;D

                  1 Reply Last reply Reply Quote 0
                  • B
                    baron164
                    last edited by

                    2.1.5 pkg v.1.0

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

                      That's the last one.

                      The widget must be there.

                      status-> dashboard -> plus button -> Varnish

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

                      Help a community developer! ;D

                      1 Reply Last reply Reply Quote 0
                      • B
                        baron164
                        last edited by

                        Here is the list I have.

                        Available Widgets

                        Captive Portal Status
                        Carp Status
                        Gateways
                        Gmirror Status
                        Installed Packages
                        Interface Statistics
                        Interfaces
                        Ipsec
                        Load Balancer Status
                        Firewall Logs
                        OpenVPN
                        Picture
                        Rss
                        Services Status
                        System Information
                        Traffic Graphs
                        Wake On Lan

                        1 Reply Last reply Reply Quote 0
                        • B
                          baron164
                          last edited by

                          So after all this I re-added the Port 80 Nat rule that forwards 80 back into the pfsense box and everything started working properly. Well for the most part at least. I still have some bugs to work out but the sites are all showing up now.

                          I'm getting messages like this occasionally now when I try to visit the sites.

                          We are very sorry but an error occurred during this request.

                          Please press refresh in your browser to try again.

                          Varnish Error 503 Service Unavailable

                          Service Unavailable

                          Guru Meditation:

                          XID: 966503285

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

                            @baron164:

                            So after all this I re-added the Port 80 Nat rule that forwards 80 back into the pfsense box and everything started working properly.

                            Sorry but this is not an option, I think you are messing up your firewall config with a nat for the same port you are listening on.

                            Remove the nat and be sure you have created a rule on wan to permit connections to port 80. Simple as that.

                            I've checked package installation and widget is there.
                            fetch it to your pfsense
                            on console do:

                            cd /usr/local/www/widgets/widgets/
                            fetch http://www.pfsense.com/packages/config/varnish64/varnish.widget.php
                            
                            

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

                            Help a community developer! ;D

                            1 Reply Last reply Reply Quote 0
                            • B
                              baron164
                              last edited by

                              Ok I removed the NAT and kept the rule but I'm still getting 503 errors.

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

                                ok, good news.

                                the 503 erros means that varnish can't check server helth status.

                                you can change the probe url from "/" to a full url that you know server responds ok.

                                fix the widget file and you will see the backend status.

                                You are almost there.  :)

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

                                Help a community developer! ;D

                                1 Reply Last reply Reply Quote 0
                                • B
                                  baron164
                                  last edited by

                                  The 503 error is intermittent though. It will work fine for a minute and then I get the error. Then 5 minutes later it breaks again.

                                  1 Reply Last reply Reply Quote 0
                                  • B
                                    baron164
                                    last edited by

                                    I installed the Widget and reworked the Probe location but I still have one site that goes green and then red again and kind of bounces back and forth.

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

                                      Varnish is a very stable solution, this intermittent error is all related to backend checks.

                                      Check again its configuration and url used for health check.

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

                                      Help a community developer! ;D

                                      1 Reply Last reply Reply Quote 0
                                      • B
                                        baron164
                                        last edited by

                                        Ok, everything seems to be running well now, only problem I'm having now is that authentication through this seems to be kind of touch and go. Outlook Web Access doesn't want to let me login. Any idea's what that's all about?

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

                                          Well,

                                          Owa is much better via https, nat 443 to owa. You do not want your domains passwords exposed.

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

                                          Help a community developer! ;D

                                          1 Reply Last reply Reply Quote 0
                                          • B
                                            baron164
                                            last edited by

                                            I would but I need 443 for a different service.

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