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

Use pfSense to redirect HTTP requests from public IP1 to public IP2

Scheduled Pinned Locked Moved General pfSense Questions
9 Posts 3 Posters 1.3k 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.
  • M
    mauro.tridici
    last edited by Apr 7, 2022, 10:50 PM

    Dear Users,

    I'm a newbie and II would like to understand if the request you can find below makes sense or not.

    One of my colleagues ask me to:

    • assign a DNS alias, let's say "web.domain.com", to the current pfSense DNS A name;
    • configure pfSense two redirect every HTTP request from "web.domain.com" to "web.domain.github.com"

    So, pfSense should redirect from an existing public IP to another external public IP. Does it make sense? Can it be done? If yes, how can I do it properly?

    In addition, I would like to ask you if it could be a transparent redirection or I should open the 80 and 443 port on WAN interface of pfSense.

    Sorry for this stupid question, but I'm still at the beginning.
    Thank you in advance.

    V 1 Reply Last reply Apr 8, 2022, 1:36 PM Reply Quote 0
    • S
      stephenw10 Netgate Administrator
      last edited by Apr 8, 2022, 12:20 AM

      Requests from behind pfSense? From clients using pfSense as their DNS server?

      Or external requests to the pfSense public IP?

      Steve

      M 1 Reply Last reply Apr 8, 2022, 12:45 AM Reply Quote 0
      • M
        mauro.tridici @stephenw10
        last edited by Apr 8, 2022, 12:45 AM

        @stephenw10 sorry, I'm in the second case. Request from external IPs to pfSense.

        Thank you

        1 Reply Last reply Reply Quote 0
        • S
          stephenw10 Netgate Administrator
          last edited by Apr 8, 2022, 12:41 PM

          Ah, then you need an http redirect which would normally be on a webserver not the firewall/router.

          You might be able to do that using HAProxy if you have to. That's not something I've ever tried though.

          Steve

          1 Reply Last reply Reply Quote 1
          • V
            viragomann @mauro.tridici
            last edited by Apr 8, 2022, 1:36 PM

            @mauro-tridici said in Use pfSense to redirect HTTP requests from public IP1 to public IP2:

            One of my colleagues ask me to:

            assign a DNS alias, let's say "web.domain.com", to the current pfSense DNS A name;
            configure pfSense two redirect every HTTP request from "web.domain.com" to "web.domain.github.com"

            So, pfSense should redirect from an existing public IP to another external public IP.

            pfSense can simply redirect packets based on destination IP / port by NAT port forwarding.
            But if you only want to redirect a certain host name you will need haproxy as already mentioned.

            In either way you have to masquerade the redirected packets to ovoid asymmetric routing issues or allow sloppy states on both, the pfSense which is redirecting and on the destination target.
            Masquerading means, pfSense has to replace the origin source address in forwarded packets with its own WAN address.

            Does it make sense?

            Depends. If it should be a temporary setup, this is a way to take a domain over to another site without interruption.

            Can it be done?

            Yes, but with some caveats due to the masquerading or sloppy states.

            In addition, I would like to ask you if it could be a transparent redirection

            Only when allowing sloppy states.

            I should open the 80 and 443 port on WAN interface of pfSense.

            A rule to pass the traffic is necessary in any rate. But since you can stated to destination IP, it's not really opening a port into your network.
            This can also be done in the NAT rule directly by selecting "pass" at firewall rule association.

            M 1 Reply Last reply Apr 8, 2022, 2:51 PM Reply Quote 1
            • M
              mauro.tridici @viragomann
              last edited by Apr 8, 2022, 2:51 PM

              @viragomann thank you for your lesson 😊 I really appreciated it. Your explanation is very useful.

              1 Reply Last reply Reply Quote 0
              • S
                stephenw10 Netgate Administrator
                last edited by Apr 8, 2022, 3:57 PM

                If you want to redirect traffic that arrives at the pfSense WAN to some other external webserver at a different location then you don't want to be routing that at all. You need to respond to the request with an http redirect so the client then connects to the new location directly.

                HAProxy can do that but oy would normally be done on an existing webserver. Installing HAProxy just to send 302 redirects would be a very unusual application. I would only do that if there is no other choice.

                Steve

                V M 2 Replies Last reply Apr 8, 2022, 3:58 PM Reply Quote 2
                • V
                  viragomann @stephenw10
                  last edited by viragomann Apr 8, 2022, 4:05 PM Apr 8, 2022, 3:58 PM

                  @stephenw10
                  Ah, yeah. That's an option, of course.

                  @mauro-tridici
                  However, if you do it on HTTP layer and it's an TLS encrypted page (HTTPS), consider that you need to install the TLS certificate on the local pfSense.

                  1 Reply Last reply Reply Quote 1
                  • M
                    mauro.tridici @stephenw10
                    last edited by Apr 8, 2022, 4:17 PM

                    @stephenw10 thank you for your help :)

                    1 Reply Last reply Reply Quote 0
                    9 out of 9
                    • First post
                      9/9
                      Last post
                    Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
                      This community forum collects and processes your personal information.
                      consent.not_received