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

    HAproxy for sub pages?

    Scheduled Pinned Locked Moved Cache/Proxy
    5 Posts 2 Posters 1.4k 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.
    • K
      killmasta93
      last edited by

      Hi,
      I was wondering if someone could assit me on a dilema been having,

      So I have 2 servers both running IIS

      server 1: 192.168.1.1

      server 2: 192.168.1.152

      The idea that the users can go to messages.mydomain.com and would point to 192.168.1.1

      and if the user goes to messages.mydomain.com/downloadswould point to 192.168.1.152

      Would this be possible?

      Thank you

      So far this is

       /var/etc/haproxy.cfg file contents:
      
      global
      	maxconn			500
      	stats socket /tmp/haproxy.socket level admin
      	uid			80
      	gid			80
      	nbproc			1
      	chroot			/tmp/haproxy_chroot
      	daemon
      
      listen HAProxyLocalStats
      	bind 127.0.0.1:2200 name localstats
      	mode http
      	stats enable
      	stats refresh 5
      	stats admin if TRUE
      	stats uri /haproxy_stats.php?haproxystats=1
      	timeout client 5000
      	timeout connect 5000
      	timeout server 5000
      
      frontend Technology
      	bind			190.X.XX.XX:80 name 190.X.XX.XX:80
      	mode			http
      	log			global
      	option			http-keep-alive
      	timeout client		30000
      	acl			aclusr_host_starts_with_messages.domain.com	hdr_beg(host) -i messages.domain.com
      	use_backend		technology_http_ipvANY if aclusr_host_starts_with_messages.domain.com 
      
      frontend Messages
      	bind			190.X.XX.XX:80 name 190.X.XX.XX:80
      	mode			http
      	log			global
      	option			http-keep-alive
      	timeout client		30000
      	acl			aclusr_host_ends_with__2fdownloads	hdr_end(host) -i /downloads
      	use_backend		Messages_http_ipvANY if aclusr_host_ends_with__2fdescargas 
      
      backend technology_http_ipvANY
      	mode			http
      	timeout connect		30000
      	timeout server		30000
      	retries			3
      	option			httpchk OPTIONS / 
      	server			technology 192.168.1.1:80 check inter 1000  
      
      backend Messages_http_ipvANY
      	mode			http
      	timeout connect		30000
      	timeout server		30000
      	retries			3
      	server			Messages 192.168.1.152:80 check inter 1000
      
      ```![Clipboarder.2017.06.12.png](/public/_imported_attachments_/1/Clipboarder.2017.06.12.png)
      ![Clipboarder.2017.06.12.png_thumb](/public/_imported_attachments_/1/Clipboarder.2017.06.12.png_thumb)
      ![Clipboarder.2017.06.12-002.png](/public/_imported_attachments_/1/Clipboarder.2017.06.12-002.png)
      ![Clipboarder.2017.06.12-002.png_thumb](/public/_imported_attachments_/1/Clipboarder.2017.06.12-002.png_thumb)
      ![Clipboarder.2017.06.12-003.png](/public/_imported_attachments_/1/Clipboarder.2017.06.12-003.png)
      ![Clipboarder.2017.06.12-003.png_thumb](/public/_imported_attachments_/1/Clipboarder.2017.06.12-003.png_thumb)
      ![Clipboarder.2017.06.12-004.png](/public/_imported_attachments_/1/Clipboarder.2017.06.12-004.png)
      ![Clipboarder.2017.06.12-004.png_thumb](/public/_imported_attachments_/1/Clipboarder.2017.06.12-004.png_thumb)
      ![Clipboarder.2017.06.12-005.png](/public/_imported_attachments_/1/Clipboarder.2017.06.12-005.png)
      ![Clipboarder.2017.06.12-005.png_thumb](/public/_imported_attachments_/1/Clipboarder.2017.06.12-005.png_thumb)

      Tutorials:

      https://www.mediafire.com/folder/v329emaz1e9ih/Tutorials

      1 Reply Last reply Reply Quote 0
      • K
        killmasta93
        last edited by

        EDIT:

        So the first part i got it working which is getting messages.mydomain.com which points internally –-192.168.1.1

        the part i cant get is when clients go to messages.mydomain.com/downloads to point internally---192.168.1.152

        Tutorials:

        https://www.mediafire.com/folder/v329emaz1e9ih/Tutorials

        1 Reply Last reply Reply Quote 0
        • P
          PiBa
          last edited by

          In above config you have originally posted there are 2 frontends configured both binding to the same IP:Port combination. That would give random results..

          For the second part is it allowable to have messages.mydomain.com/downloads to point internally to: 192.168.1.152/downloads ?
          As that should be relatively easy to configure, if you need to rewrite the url that might be possible, but then its highly likely that the response will contain wrong links/references to otger pages/css/js content.. Currently haproxy cannot rewrite a response body.

          1 Reply Last reply Reply Quote 0
          • K
            killmasta93
            last edited by

            Thanks for the reply,

            as you right for the 2 frontends with the both binding IP port so quick question do you recommend maybe changing the port 80 to port 81 for the IP 192.168.1.152 and would that work?

            as for the rewrite rule the 192.168.1.152 when entered on the URL shows a webpage with directories if clicked then would go the page so in this case if i go to 192.168.1.152/downloads shows me the page, I see what you mean or would you recommend better messages.mydomain.com to point to 192.168.1.1
            and clients.mydomain.com to point to 192.168.1.152?

            Thank you

              /var/etc/haproxy.cfg file contents:
            
            global
            	maxconn			500
            	stats socket /tmp/haproxy.socket level admin
            	uid			80
            	gid			80
            	nbproc			1
            	chroot			/tmp/haproxy_chroot
            	daemon
            
            listen HAProxyLocalStats
            	bind 127.0.0.1:2200 name localstats
            	mode http
            	stats enable
            	stats refresh 5
            	stats admin if TRUE
            	stats uri /haproxy_stats.php?haproxystats=1
            	timeout client 5000
            	timeout connect 5000
            	timeout server 5000
            
            frontend 192.168.1.1
            	bind			1XX.XX.XXX:80 name 1XX.XX.XXX:80   
            	mode			http
            	log			global
            	option			http-keep-alive
            	timeout client		30000
            	acl			aclusr_host_matches_messages.mydomain.com	hdr(host) -i messages.mydomain.com
            	use_backend		192.168.1.1_http_ipvANY if aclusr_host_matches_messages.mydomain.com 
            
            frontend 192.168.1.152
            	bind			1XX.XX.XXX:80name 1XX.XX.XXX:80   
            	mode			http
            	log			global
            	option			http-keep-alive
            	timeout client		30000
            	acl			aclusr_path_starts_with__2fdownloads	path_beg -i /downloads
            	use_backend		192.168.1.152_http_ipvANY if aclusr_path_starts_with__2fdownloads 
            
            backend 192.168.1.1_http_ipvANY
            	mode			http
            	timeout connect		30000
            	timeout server		30000
            	retries			3
            	option			httpchk OPTIONS / 
            	server			technology 192.168.1.1:80 check inter 1000  
            
            backend 192.168.1.152_http_ipvANY
            	mode			http
            	timeout connect		30000
            	timeout server		30000
            	retries			3
            	option			httpchk OPTIONS / 
            	server			Messages 192.168.1.152:80 check inter 1000
            
            

            Tutorials:

            https://www.mediafire.com/folder/v329emaz1e9ih/Tutorials

            1 Reply Last reply Reply Quote 0
            • P
              PiBa
              last edited by

              Having it like:
              messages.mydomain.com to point to 192.168.1.1
              clients.mydomain.com to point to 192.168.1.152
              Should probably work nicely..

              As for the frontends make sure to make them 'shared' as the webgui calls it. Or use just use one frontend it the gui, and use the acl+action to select the second backend for the second domain.

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